[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/ -> announcements.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('THIS_SCRIPT', 'announcements.php');
  13  
  14  $templatelist = "announcement,postbit_groupimage,postbit_reputation,postbit_avatar,postbit_online,postbit_offline,postbit_away,postbit_find,postbit_pm,postbit_email,postbit_author_user";
  15  $templatelist .= ",forumdisplay_password_wrongpass,forumdisplay_password,postbit_author_guest,postbit_userstar,announcement_quickdelete,postbit,postbit_classic,postbit_www,announcement_edit";
  16  
  17  require_once  "./global.php";
  18  require_once  MYBB_ROOT."inc/functions_post.php";
  19  
  20  // Load global language phrases
  21  $lang->load("announcements");
  22  
  23  $aid = $mybb->get_input('aid', MyBB::INPUT_INT);
  24  
  25  // Get announcement fid
  26  $query = $db->simple_select("announcements", "fid", "aid='$aid'");
  27  $announcement = $db->fetch_array($query);
  28  
  29  $plugins->run_hooks("announcements_start");
  30  
  31  if(!$announcement)
  32  {
  33      error($lang->error_invalidannouncement);
  34  }
  35  
  36  // Get forum info
  37  $fid = $announcement['fid'];
  38  if($fid > 0)
  39  {
  40      $forum = get_forum($fid);
  41  
  42      if(!$forum)
  43      {
  44          error($lang->error_invalidforum);
  45      }
  46  
  47      // Make navigation
  48      build_forum_breadcrumb($forum['fid']);
  49  
  50      // Permissions
  51      $forumpermissions = forum_permissions($forum['fid']);
  52  
  53      if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  54      {
  55          error_no_permission();
  56      }
  57  
  58      // Check if this forum is password protected and we have a valid password
  59      check_forum_password($forum['fid']);
  60  }
  61  add_breadcrumb($lang->nav_announcements);
  62  
  63  $archive_url = build_archive_link("announcement", $aid);
  64  
  65  // Get announcement info
  66  $time = TIME_NOW;
  67  
  68  $query = $db->query("
  69      SELECT u.*, u.username AS userusername, a.*, f.*
  70      FROM ".TABLE_PREFIX."announcements a
  71      LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
  72      LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
  73      WHERE a.startdate<='$time' AND (a.enddate>='$time' OR a.enddate='0') AND a.aid='$aid'
  74  ");
  75  
  76  $announcementarray = $db->fetch_array($query);
  77  
  78  if(!$announcementarray)
  79  {
  80      error($lang->error_invalidannouncement);
  81  }
  82  
  83  // Gather usergroup data from the cache
  84  // Field => Array Key
  85  $data_key = array(
  86      'title' => 'grouptitle',
  87      'usertitle' => 'groupusertitle',
  88      'stars' => 'groupstars',
  89      'starimage' => 'groupstarimage',
  90      'image' => 'groupimage',
  91      'namestyle' => 'namestyle',
  92      'usereputationsystem' => 'usereputationsystem'
  93  );
  94  
  95  foreach($data_key as $field => $key)
  96  {
  97      $announcementarray[$key] = $groupscache[$announcementarray['usergroup']][$field];
  98  }
  99  
 100  $announcementarray['dateline'] = $announcementarray['startdate'];
 101  $announcementarray['userusername'] = $announcementarray['username'];
 102  $announcement = build_postbit($announcementarray, 3);
 103  $announcementarray['subject'] = $parser->parse_badwords($announcementarray['subject']);
 104  $lang->forum_announcement = $lang->sprintf($lang->forum_announcement, htmlspecialchars_uni($announcementarray['subject']));
 105  
 106  if($announcementarray['startdate'] > $mybb->user['lastvisit'])
 107  {
 108      $setcookie = true;
 109      if(isset($mybb->cookies['mybb']['announcements']) && is_scalar($mybb->cookies['mybb']['announcements']))
 110      {
 111          $cookie = my_unserialize(stripslashes($mybb->cookies['mybb']['announcements']), false);
 112  
 113          if(isset($cookie[$announcementarray['aid']]))
 114          {
 115              $setcookie = false;
 116          }
 117      }
 118  
 119      if($setcookie)
 120      {
 121          my_set_array_cookie('announcements', $announcementarray['aid'], $announcementarray['startdate'], -1);
 122      }
 123  }
 124  
 125  $plugins->run_hooks("announcements_end");
 126  
 127  eval("\$forumannouncement = \"".$templates->get("announcement")."\";");
 128  output_page($forumannouncement);


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