[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/ -> portal.php (source)

   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("IN_PORTAL", 1);
  13  define('THIS_SCRIPT', 'portal.php');
  14  
  15  // set the path to your forums directory here (without trailing slash)
  16  $forumdir = "./";
  17  
  18  // end editing
  19  
  20  $change_dir = "./";
  21  
  22  if(!@chdir($forumdir) && !empty($forumdir))
  23  {
  24      if(@is_dir($forumdir))
  25      {
  26          $change_dir = $forumdir;
  27      }
  28      else
  29      {
  30          die("\$forumdir is invalid!");
  31      }
  32  }
  33  
  34  $templatelist = "portal,portal_welcome_membertext,portal_stats,portal_search,portal_whosonline_memberbit,portal_whosonline,portal_latestthreads_thread,portal_latestthreads,portal_announcement_numcomments_no";
  35  $templatelist .= ",postbit_attachments_thumbnails_thumbnail,postbit_attachments_images_image,postbit_attachments_attachment,postbit_attachments_thumbnails,postbit_attachments_images,postbit_attachments";
  36  $templatelist .= ",multipage,multipage_end,multipage_jump_page,multipage_nextpage,multipage_page,multipage_page_current,multipage_page_link_current,multipage_prevpage,multipage_start,portal_announcement_send_item";
  37  $templatelist .= ",portal_stats_nobody,portal_announcement_avatar,portal_announcement_numcomments,portal_announcement_icon,portal_pms,portal_welcome,portal_announcement,portal_welcome_guesttext";
  38  
  39  require_once $change_dir."/global.php";
  40  require_once  MYBB_ROOT."inc/functions_post.php";
  41  require_once  MYBB_ROOT."inc/functions_user.php";
  42  require_once  MYBB_ROOT."inc/class_parser.php";
  43  $parser = new postParser;
  44  
  45  // Load global language phrases
  46  $lang->load("portal");
  47  
  48  if($mybb->settings['portal'] == 0)
  49  {
  50      error($lang->portal_disabled);
  51  }
  52  
  53  // Fetch the current URL
  54  $portal_url = get_current_location();
  55  $file_name = strtok(my_strtolower(basename($portal_url)), '?');
  56  
  57  add_breadcrumb($lang->nav_portal, $file_name);
  58  
  59  $plugins->run_hooks("portal_start");
  60  
  61  $tunviewwhere = $unviewwhere = '';
  62  // get forums user cannot view
  63  $unviewable = get_unviewable_forums(true);
  64  if($unviewable)
  65  {
  66      $unviewwhere = " AND fid NOT IN ($unviewable)";
  67      $tunviewwhere = " AND t.fid NOT IN ($unviewable)";
  68  }
  69  
  70  // get inactive forums
  71  $inactive = get_inactive_forums();
  72  if($inactive)
  73  {
  74      $unviewwhere .= " AND fid NOT IN ($inactive)";
  75      $tunviewwhere .= " AND t.fid NOT IN ($inactive)";
  76  }
  77  
  78  $mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']);
  79  
  80  $welcome = '';
  81  // If user is known, welcome them
  82  if($mybb->settings['portal_showwelcome'] != 0)
  83  {
  84      if($mybb->user['uid'] != 0)
  85      {
  86          // Get number of new posts, threads, announcements
  87          $query = $db->simple_select("posts", "COUNT(pid) AS newposts", "visible=1 AND dateline>'".$mybb->user['lastvisit']."'{$unviewwhere}");
  88          $newposts = $db->fetch_field($query, "newposts");
  89          if($newposts)
  90          {
  91              // If there aren't any new posts, there is no point in wasting two more queries
  92              $query = $db->simple_select("threads", "COUNT(tid) AS newthreads", "visible=1 AND dateline>'".$mybb->user['lastvisit']."'{$unviewwhere}");
  93              $newthreads = $db->fetch_field($query, "newthreads");
  94  
  95              $newann = 0;
  96              if(!empty($mybb->settings['portal_announcementsfid']))
  97              {
  98                  $annfidswhere = '';
  99                  if($mybb->settings['portal_announcementsfid'] != -1)
 100                  {
 101                      $announcementsfids = explode(',', (string)$mybb->settings['portal_announcementsfid']);
 102                      if(is_array($announcementsfids))
 103                      {
 104                          foreach($announcementsfids as &$fid)
 105                          {
 106                              $fid = (int)$fid;
 107                          }
 108                          unset($fid);
 109  
 110                          $announcementsfids = implode(',', $announcementsfids);
 111  
 112                          $annfidswhere = " AND fid IN (".$announcementsfids.")";
 113                      }
 114                  }
 115  
 116                  $query = $db->simple_select("threads", "COUNT(tid) AS newann", "visible=1 AND dateline>'".$mybb->user['lastvisit']."'{$annfidswhere}{$unviewwhere}");
 117                  $newann = $db->fetch_field($query, "newann");
 118              }
 119          }
 120          else
 121          {
 122              $newposts = 0;
 123              $newthreads = 0;
 124              $newann = 0;
 125          }
 126  
 127          // Make the text
 128          if($newann == 1)
 129          {
 130              $lang->new_announcements = $lang->new_announcement;
 131          }
 132          else
 133          {
 134              $lang->new_announcements = $lang->sprintf($lang->new_announcements, $newann);
 135          }
 136          if($newthreads == 1)
 137          {
 138              $lang->new_threads = $lang->new_thread;
 139          }
 140          else
 141          {
 142              $lang->new_threads = $lang->sprintf($lang->new_threads, $newthreads);
 143          }
 144          if($newposts == 1)
 145          {
 146              $lang->new_posts = $lang->new_post;
 147          }
 148          else
 149          {
 150              $lang->new_posts = $lang->sprintf($lang->new_posts, $newposts);
 151          }
 152          eval("\$welcometext = \"".$templates->get("portal_welcome_membertext")."\";");
 153  
 154      }
 155      else
 156      {
 157          $lang->guest_welcome_registration = $lang->sprintf($lang->guest_welcome_registration, $mybb->settings['bburl'].'/member.php?action=register');
 158          $mybb->user['username'] = $lang->guest;
 159          switch($mybb->settings['username_method'])
 160          {
 161              case 0:
 162                  $username = $lang->username;
 163                  break;
 164              case 1:
 165                  $username = $lang->username1;
 166                  break;
 167              case 2:
 168                  $username = $lang->username2;
 169                  break;
 170              default:
 171                  $username = $lang->username;
 172                  break;
 173          }
 174          eval("\$welcometext = \"".$templates->get("portal_welcome_guesttext")."\";");
 175      }
 176      $lang->welcome = $lang->sprintf($lang->welcome, $mybb->user['username']);
 177      eval("\$welcome = \"".$templates->get("portal_welcome")."\";");
 178  }
 179  
 180  $pms = '';
 181  // Private messages box
 182  if($mybb->settings['portal_showpms'] != 0)
 183  {
 184      if($mybb->user['uid'] != 0 && $mybb->user['receivepms'] != 0 && $mybb->usergroup['canusepms'] != 0 && $mybb->settings['enablepms'] != 0)
 185      {
 186          $messages['pms_total'] = $mybb->user['pms_total'];
 187          $messages['pms_unread'] = $mybb->user['pms_unread'];
 188  
 189          $lang->pms_received_new = $lang->sprintf($lang->pms_received_new, $mybb->user['username'], $messages['pms_unread']);
 190          eval("\$pms = \"".$templates->get("portal_pms")."\";");
 191      }
 192  }
 193  
 194  $stats = '';
 195  // Get Forum Statistics
 196  if($mybb->settings['portal_showstats'] != 0)
 197  {
 198      $stats = $cache->read("stats");
 199      $stats['numthreads'] = my_number_format($stats['numthreads']);
 200      $stats['numposts'] = my_number_format($stats['numposts']);
 201      $stats['numusers'] = my_number_format($stats['numusers']);
 202      if(!$stats['lastusername'])
 203      {
 204          eval("\$newestmember = \"".$templates->get("portal_stats_nobody")."\";");
 205      }
 206      else
 207      {
 208          $newestmember = build_profile_link($stats['lastusername'], $stats['lastuid']);
 209      }
 210      eval("\$stats = \"".$templates->get("portal_stats")."\";");
 211  }
 212  
 213  $search = '';
 214  // Search box
 215  if($mybb->settings['portal_showsearch'] != 0)
 216  {
 217      eval("\$search = \"".$templates->get("portal_search")."\";");
 218  }
 219  
 220  $onlinecount = null;
 221  $whosonline = '';
 222  // Get the online users
 223  if($mybb->settings['portal_showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0)
 224  {
 225      if($mybb->settings['wolorder'] == 'username')
 226      {
 227          $order_by = 'u.username ASC';
 228          $order_by2 = 's.time DESC';
 229      }
 230      else
 231      {
 232          $order_by = 's.time DESC';
 233          $order_by2 = 'u.username ASC';
 234      }
 235  
 236      $timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
 237      $guestcount = $membercount = $botcount = $anoncount = 0;
 238      $doneusers = $onlinemembers = $onlinebots = array();
 239  
 240      $query = $db->simple_select("sessions", "COUNT(DISTINCT ip) AS guestcount", "uid = 0 AND time > $timesearch");
 241      $guestcount = $db->fetch_field($query, "guestcount");
 242  
 243      $query = $db->query("
 244          SELECT
 245              s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup
 246          FROM
 247              ".TABLE_PREFIX."sessions s
 248              LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
 249          WHERE (s.uid != 0 OR SUBSTR(s.sid,4,1) = '=') AND s.time > $timesearch
 250          ORDER BY {$order_by}, {$order_by2}
 251      ");
 252  
 253      // Fetch spiders
 254      $spiders = $cache->read('spiders');
 255  
 256      while($user = $db->fetch_array($query))
 257      {
 258  
 259          // Create a key to test if this user is a search bot.
 260          $botkey = my_strtolower(str_replace("bot=", '', $user['sid']));
 261  
 262          if($user['uid'] > 0)
 263          {
 264              if(empty($doneusers[$user['uid']]) || $doneusers[$user['uid']] < $user['time'])
 265              {
 266                  ++$membercount;
 267  
 268                  $doneusers[$user['uid']] = $user['time'];
 269  
 270                  // If the user is logged in anonymously, update the count for that.
 271                  if($user['invisible'] == 1)
 272                  {
 273                      ++$anoncount;
 274                  }
 275  
 276                  if($user['invisible'] == 1)
 277                  {
 278                      $invisiblemark = "*";
 279                  }
 280                  else
 281                  {
 282                      $invisiblemark = '';
 283                  }
 284  
 285                  if(($user['invisible'] == 1 && ($mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])) || $user['invisible'] != 1)
 286                  {
 287                      $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
 288                      $user['profilelink'] = get_profile_link($user['uid']);
 289                      eval("\$onlinemembers[] = \"".$templates->get("portal_whosonline_memberbit", 1, 0)."\";");
 290                  }
 291              }
 292          }
 293          elseif(my_strpos($user['sid'], 'bot=') !== false && $spiders[$botkey] && $mybb->settings['woldisplayspiders'] == 1)
 294          {
 295              // The user is a search bot.
 296              if($mybb->settings['wolorder'] == 'username')
 297              {
 298                  $key = $spiders[$botkey]['name'];
 299              }
 300              else
 301              {
 302                  $key = $user['time'];
 303              }
 304  
 305              $onlinebots[$key] = format_name($spiders[$botkey]['name'], $spiders[$botkey]['usergroup']);
 306              ++$botcount;
 307          }
 308      }
 309  
 310      if($mybb->settings['wolorder'] == 'activity')
 311      {
 312          // activity ordering is DESC, username is ASC
 313          krsort($onlinebots);
 314      }
 315      else
 316      {
 317          ksort($onlinebots);
 318      }
 319  
 320      $onlinemembers = array_merge($onlinebots, $onlinemembers);
 321      if(!empty($onlinemembers))
 322      {
 323          $comma = $lang->comma." ";
 324          $onlinemembers = implode($comma, $onlinemembers);
 325      }
 326      else
 327      {
 328          $onlinemembers = "";
 329      }
 330  
 331      $onlinecount = $membercount + $guestcount + $botcount;
 332  
 333      // If we can see invisible users add them to the count
 334      if($mybb->usergroup['canviewwolinvis'] == 1)
 335      {
 336          $onlinecount += $anoncount;
 337      }
 338  
 339      // If we can't see invisible users but the user is an invisible user incriment the count by one
 340      if($mybb->usergroup['canviewwolinvis'] != 1 && isset($mybb->user['invisible']) && $mybb->user['invisible'] == 1)
 341      {
 342          ++$onlinecount;
 343      }
 344  
 345      // Most users online
 346      $mostonline = $cache->read("mostonline");
 347      if($onlinecount !== null && $onlinecount > $mostonline['numusers'])
 348      {
 349          $time = TIME_NOW;
 350          $mostonline['numusers'] = $onlinecount;
 351          $mostonline['time'] = $time;
 352          $cache->update("mostonline", $mostonline);
 353      }
 354      $recordcount = $mostonline['numusers'];
 355      $recorddate = my_date('relative', $mostonline['time']);
 356  
 357      if($onlinecount == 1)
 358      {
 359        $lang->online_users = $lang->online_user;
 360      }
 361      else
 362      {
 363        $lang->online_users = $lang->sprintf($lang->online_users, $onlinecount);
 364      }
 365      $lang->online_counts = $lang->sprintf($lang->online_counts, $membercount, $guestcount);
 366      eval("\$whosonline = \"".$templates->get("portal_whosonline")."\";");
 367  }
 368  
 369  $latestthreads = '';
 370  // Latest forum discussions
 371  if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'] && $mybb->settings['portal_excludediscussion'] != -1)
 372  {
 373      $altbg = alt_trow();
 374      $threadlist = '';
 375  
 376      $excludeforums = '';
 377      if(!empty($mybb->settings['portal_excludediscussion']))
 378      {
 379          $excludeforums = "AND t.fid NOT IN ({$mybb->settings['portal_excludediscussion']})";
 380      }
 381  
 382      $query = $db->query("
 383          SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
 384          FROM ".TABLE_PREFIX."threads t
 385          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
 386          WHERE 1=1 {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
 387          ORDER BY t.lastpost DESC
 388          LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
 389      );
 390      while($thread = $db->fetch_array($query))
 391      {
 392          $forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
 393  
 394          // Make sure we can view this thread
 395          if(isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
 396          {
 397              continue;
 398          }
 399  
 400          $lastpostdate = my_date('relative', $thread['lastpost']);
 401          if(!$thread['lastposteruid'] && !$thread['lastposter'])
 402          {
 403              $lastposter = htmlspecialchars_uni($lang->guest);
 404          }
 405          else
 406          {
 407              $lastposter = htmlspecialchars_uni($thread['lastposter']);
 408          }
 409          $thread['replies'] = my_number_format($thread['replies']);
 410          $thread['views'] = my_number_format($thread['views']);
 411  
 412          // Don't link to guest's profiles (they have no profile).
 413          if($thread['lastposteruid'] == 0)
 414          {
 415              $lastposterlink = $lastposter;
 416          }
 417          else
 418          {
 419              $lastposterlink = build_profile_link($lastposter, $thread['lastposteruid']);
 420          }
 421  
 422          $thread['subject'] = $thread['fullsubject'] = $parser->parse_badwords($thread['subject']);
 423          if(my_strlen($thread['subject']) > 25)
 424          {
 425              $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
 426          }
 427          $thread['subject'] = htmlspecialchars_uni($thread['subject']);
 428          $thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']);
 429  
 430          $thread['threadlink'] = get_thread_link($thread['tid']);
 431          $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
 432          $thread['forumlink'] = get_forum_link($thread['fid']);
 433          $thread['forumname'] = $forum_cache[$thread['fid']]['name'];
 434          eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
 435          $altbg = alt_trow();
 436      }
 437      if($threadlist)
 438      {
 439          // Show the table only if there are threads
 440          eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
 441      }
 442  }
 443  
 444  $announcements = '';
 445  if(!empty($mybb->settings['portal_announcementsfid']))
 446  {
 447      // Get latest news announcements
 448      // Build where clause
 449      $annfidswhere = '';
 450      $announcementcount = 0;
 451      if($mybb->settings['portal_announcementsfid'] != -1)
 452      {
 453          // First validate announcement fids:
 454          $announcementsfids = explode(',', (string)$mybb->settings['portal_announcementsfid']);
 455          if(is_array($announcementsfids))
 456          {
 457              foreach($announcementsfids as $fid)
 458              {
 459                  $fid_array[] = (int)$fid;
 460              }
 461              unset($fid);
 462  
 463              $announcementsfids = implode(',', $fid_array);
 464  
 465              $annfidswhere = " AND t.fid IN ($announcementsfids)";
 466          }
 467      }
 468  
 469      // And get them!
 470      foreach($forum_cache as $fid => $f)
 471      {
 472          if(empty($fid_array) || (is_array($fid_array) && in_array($fid, $fid_array)))
 473          {
 474              $forum[$fid] = $f;
 475          }
 476      }
 477  
 478      $query = $db->simple_select("threads t", "COUNT(t.tid) AS threads", "t.visible='1'{$annfidswhere}{$tunviewwhere} AND t.closed NOT LIKE 'moved|%'", array('limit' => 1));
 479      $announcementcount = $db->fetch_field($query, "threads");
 480  
 481      $numannouncements = (int)$mybb->settings['portal_numannouncements'];
 482      if(!$numannouncements)
 483      {
 484          $numannouncements = 10; // Default back to 10
 485      }
 486  
 487      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 488      $pages = $announcementcount / $numannouncements;
 489      $pages = ceil($pages);
 490  
 491      if($page > $pages || $page <= 0)
 492      {
 493          $page = 1;
 494      }
 495  
 496      if($page)
 497      {
 498          $start = ($page-1) * $numannouncements;
 499      }
 500      else
 501      {
 502          $start = 0;
 503          $page = 1;
 504      }
 505  
 506      $multipage = multipage($announcementcount, $numannouncements, $page, $file_name);
 507  
 508      $pids = '';
 509      $tids = '';
 510      $comma = '';
 511      $posts = array();
 512      $attachmentcount = array();
 513      $query = $db->query("
 514          SELECT p.pid, p.message, p.tid, p.smilieoff, t.attachmentcount
 515          FROM ".TABLE_PREFIX."posts p
 516          LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
 517          WHERE t.visible='1'{$annfidswhere}{$tunviewwhere} AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
 518          ORDER BY t.dateline DESC
 519          LIMIT {$start}, {$numannouncements}"
 520      );
 521      while($getid = $db->fetch_array($query))
 522      {
 523          $attachmentcount[$getid['tid']] = $getid['attachmentcount'];
 524          foreach($attachmentcount as $tid => $attach_count)
 525          {
 526              if($attach_count > 0)
 527              {
 528                  $pids .= ",'{$getid['pid']}'";
 529              }
 530  
 531              $posts[$getid['tid']] = $getid;
 532          }
 533  
 534          $tids .= ",'{$getid['tid']}'";
 535      }
 536      if(!empty($posts))
 537      {
 538          if($pids != '' && $mybb->settings['enableattachments'] == 1)
 539          {
 540              $pids = "pid IN(0{$pids})";
 541              // Now lets fetch all of the attachments for these posts
 542              $query = $db->simple_select("attachments", "*", $pids);
 543              while($attachment = $db->fetch_array($query))
 544              {
 545                  $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
 546              }
 547          }
 548  
 549          if(is_array($forum))
 550          {
 551              foreach($forum as $fid => $forumrow)
 552              {
 553                  $forumpermissions[$fid] = forum_permissions($fid);
 554              }
 555          }
 556  
 557          $icon_cache = $cache->read("posticons");
 558  
 559          $query = $db->query("
 560              SELECT t.*, t.username AS threadusername, u.username, u.avatar, u.avatardimensions
 561              FROM ".TABLE_PREFIX."threads t
 562              LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
 563              WHERE t.tid IN (0{$tids}){$annfidswhere}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
 564              ORDER BY t.dateline DESC
 565              LIMIT 0, {$numannouncements}"
 566          );
 567          while($announcement = $db->fetch_array($query))
 568          {
 569              // Make sure we can view this announcement
 570              if(isset($forumpermissions[$announcement['fid']]['canonlyviewownthreads']) && $forumpermissions[$announcement['fid']]['canonlyviewownthreads'] == 1 && $announcement['uid'] != $mybb->user['uid'])
 571              {
 572                  continue;
 573              }
 574  
 575              $announcement['message'] = $posts[$announcement['tid']]['message'];
 576              $announcement['pid'] = $posts[$announcement['tid']]['pid'];
 577              $announcement['smilieoff'] = $posts[$announcement['tid']]['smilieoff'];
 578              $announcement['threadlink'] = get_thread_link($announcement['tid']);
 579              $announcement['forumlink'] = get_forum_link($announcement['fid']);
 580              $announcement['forumname'] = $forum_cache[$announcement['fid']]['name'];
 581              $announcement['username'] = htmlspecialchars_uni($announcement['username']);
 582              if(!$announcement['uid'] && !$announcement['threadusername'])
 583              {
 584                  $announcement['threadusername'] = htmlspecialchars_uni($lang->guest);
 585              }
 586              else
 587              {
 588                  $announcement['threadusername'] = htmlspecialchars_uni($announcement['threadusername']);
 589              }
 590  
 591              if($announcement['uid'] == 0)
 592              {
 593                  $profilelink = $announcement['threadusername'];
 594              }
 595              else
 596              {
 597                  $profilelink = build_profile_link($announcement['username'], $announcement['uid']);
 598              }
 599  
 600              if(!$announcement['username'])
 601              {
 602                  $announcement['username'] = $announcement['threadusername'];
 603              }
 604              $announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
 605              if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
 606              {
 607                  $icon = $icon_cache[$announcement['icon']];
 608                  $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
 609                  $icon['path'] = htmlspecialchars_uni($icon['path']);
 610                  $icon['name'] = htmlspecialchars_uni($icon['name']);
 611                  eval("\$icon = \"".$templates->get("portal_announcement_icon")."\";");
 612              }
 613              else
 614              {
 615                  $icon = "&nbsp;";
 616              }
 617  
 618              $useravatar = format_avatar($announcement['avatar'], $announcement['avatardimensions']);
 619              eval("\$avatar = \"".$templates->get("portal_announcement_avatar")."\";");
 620  
 621              $anndate = my_date('relative', $announcement['dateline']);
 622  
 623              if($announcement['replies'])
 624              {
 625                  eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments")."\";");
 626              }
 627              else
 628              {
 629                  eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments_no")."\";");
 630                  $lastcomment = '';
 631              }
 632  
 633              $senditem = '';
 634              if($mybb->user['uid'] > 0 && $mybb->usergroup['cansendemail'] == 1)
 635              {
 636                  eval("\$senditem = \"".$templates->get("portal_announcement_send_item")."\";");
 637              }
 638  
 639              $plugins->run_hooks("portal_announcement");
 640  
 641              $parser_options = array(
 642                  "allow_html" => $mybb->settings['announcementshtml'] && $forum[$announcement['fid']]['allowhtml'],
 643                  "allow_mycode" => $forum[$announcement['fid']]['allowmycode'],
 644                  "allow_smilies" => $forum[$announcement['fid']]['allowsmilies'],
 645                  "allow_imgcode" => $forum[$announcement['fid']]['allowimgcode'],
 646                  "allow_videocode" => $forum[$announcement['fid']]['allowvideocode'],
 647                  "filter_badwords" => 1
 648              );
 649              if($announcement['smilieoff'] == 1)
 650              {
 651                  $parser_options['allow_smilies'] = 0;
 652              }
 653  
 654              if($mybb->user['uid'] != 0 && $mybb->user['showimages'] != 1 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0)
 655              {
 656                  $parser_options['allow_imgcode'] = 0;
 657              }
 658  
 659              if($mybb->user['uid'] != 0 && $mybb->user['showvideos'] != 1 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0)
 660              {
 661                  $parser_options['allow_videocode'] = 0;
 662              }
 663  
 664              $message = $parser->parse_message($announcement['message'], $parser_options);
 665  
 666              $post['attachments'] = '';
 667              if($mybb->settings['enableattachments'] == 1 && isset($attachcache[$announcement['pid']]) && is_array($attachcache[$announcement['pid']]))
 668              { // This post has 1 or more attachments
 669                  $validationcount = 0;
 670                  $id = $announcement['pid'];
 671                  $post['attachmentlist'] = $post['thumblist'] = $post['imagelist'] = $post['attachedthumbs'] = $post['attachedimages'] = '';
 672                  foreach($attachcache[$id] as $aid => $attachment)
 673                  {
 674                      if($attachment['visible'])
 675                      { // There is an attachment thats visible!
 676                          $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
 677                          $attachment['filesize'] = get_friendly_size($attachment['filesize']);
 678                          $ext = get_extension($attachment['filename']);
 679                          if($ext == "jpeg" || $ext == "gif" || $ext == "bmp" || $ext == "png" || $ext == "jpg")
 680                          {
 681                              $isimage = true;
 682                          }
 683                          else
 684                          {
 685                              $isimage = false;
 686                          }
 687                          $attachment['icon'] = get_attachment_icon($ext);
 688                          if(!$attachment['dateuploaded'])
 689                          {
 690                              $attachment['dateuploaded'] = $announcement['dateline'];
 691                          }
 692                          $attachdate = my_date('normal', $attachment['dateuploaded']);
 693                          // Support for [attachment=id] code
 694                          if(stripos($message, "[attachment=".$attachment['aid']."]") !== false)
 695                          {
 696                              if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != '')
 697                              { // We have a thumbnail to show (and its not the "SMALL" enough image
 698                                  eval("\$attbit = \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";");
 699                              }
 700                              elseif($attachment['thumbnail'] == "SMALL" && $forumpermissions[$announcement['fid']]['candlattachments'] == 1)
 701                              {
 702                                  // Image is small enough to show - no thumbnail
 703                                  eval("\$attbit = \"".$templates->get("postbit_attachments_images_image")."\";");
 704                              }
 705                              else
 706                              {
 707                                  // Show standard link to attachment
 708                                  eval("\$attbit = \"".$templates->get("postbit_attachments_attachment")."\";");
 709                              }
 710                              $message = preg_replace("#\[attachment=".$attachment['aid']."]#si", $attbit, $message);
 711                          }
 712                          else
 713                          {
 714                              if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != '')
 715                              { // We have a thumbnail to show
 716                                  eval("\$post['thumblist'] .= \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";");
 717                                  if($tcount == 5)
 718                                  {
 719                                      $post['thumblist'] .= "<br />";
 720                                      $tcount = 0;
 721                                  }
 722                                  ++$tcount;
 723                              }
 724                              elseif($attachment['thumbnail'] == "SMALL" && $forumpermissions[$announcement['fid']]['candlattachments'] == 1)
 725                              {
 726                                  // Image is small enough to show - no thumbnail
 727                                  eval("\$post['imagelist'] .= \"".$templates->get("postbit_attachments_images_image")."\";");
 728                              }
 729                              else
 730                              {
 731                                  eval("\$post['attachmentlist'] .= \"".$templates->get("postbit_attachments_attachment")."\";");
 732                              }
 733                          }
 734                      }
 735                      else
 736                      {
 737                          $validationcount++;
 738                      }
 739                  }
 740                  if($post['thumblist'])
 741                  {
 742                      eval("\$post['attachedthumbs'] = \"".$templates->get("postbit_attachments_thumbnails")."\";");
 743                  }
 744                  if($post['imagelist'])
 745                  {
 746                      eval("\$post['attachedimages'] = \"".$templates->get("postbit_attachments_images")."\";");
 747                  }
 748                  if($post['attachmentlist'] || $post['thumblist'] || $post['imagelist'])
 749                  {
 750                      eval("\$post['attachments'] = \"".$templates->get("postbit_attachments")."\";");
 751                  }
 752              }
 753  
 754              eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
 755              unset($post);
 756          }
 757      }
 758  }
 759  
 760  $plugins->run_hooks("portal_end");
 761  
 762  eval("\$portal = \"".$templates->get("portal")."\";");
 763  output_page($portal);


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref