[ Index ]

PHP Cross Reference of MyBB 1.8.12

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


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