Advertisement
Guest User

Untitled

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