[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/inc/ -> functions_archive.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  /**
  13   * Output the archive page header.
  14   *
  15   * @param string The page title.
  16   * @param string The full page title.
  17   * @param string The full page URL.
  18   */
  19  function archive_header($title="", $fulltitle="", $fullurl="")
  20  {
  21      global $mybb, $lang, $db, $nav, $archiveurl, $sent_header;
  22  
  23      // Build the archive navigation.
  24      $nav = archive_navigation();
  25  
  26      // If there is a title, append it to the bbname.
  27      if(!$title)
  28      {
  29          $title = $mybb->settings['bbname'];
  30      }
  31      else
  32      {
  33          $title = $mybb->settings['bbname']." - ".$title;
  34      }
  35  
  36      // If the language doesn't have a charset, make it UTF-8.
  37      if($lang->settings['charset'])
  38      {
  39          $charset = $lang->settings['charset'];
  40      }
  41      else
  42      {
  43          $charset = "utf-8";
  44      }
  45  
  46      $dir = '';
  47      if($lang->settings['rtl'] == 1)
  48      {
  49          $dir = " dir=\"rtl\"";
  50      }
  51  
  52      if($lang->settings['htmllang'])
  53      {
  54          $htmllang = " xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"";
  55      }
  56      else
  57      {
  58          $htmllang = " xml:lang=\"en\" lang=\"en\"";
  59      }
  60  ?>
  61  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62  <html xmlns="http://www.w3.org/1999/xhtml"<?php echo $dir; echo $htmllang; ?>>
  63  <head>
  64  <title><?php echo $title; ?></title>
  65  <meta http-equiv="content-type" content="text/html; charset=<?php echo $charset; ?>" />
  66  <meta name="robots" content="index,follow" />
  67  <link type="text/css" rel="stylesheet" rev="stylesheet" href="<?php echo $archiveurl; ?>/screen.css" media="screen" />
  68  <link type="text/css" rel="stylesheet" rev="stylesheet" href="<?php echo $archiveurl; ?>/print.css" media="print" />
  69  </head>
  70  <body>
  71  <div id="container">
  72  <h1><a href="<?php echo $mybb->settings['bburl']; ?>/index.php"><?php echo $mybb->settings['bbname_orig']; ?></a></h1>
  73  <div class="navigation"><?php echo $nav; ?></div>
  74  <div id="fullversion"><strong><?php echo $lang->archive_fullversion; ?></strong> <a href="<?php echo $fullurl; ?>"><?php echo $fulltitle; ?></a></div>
  75  <div id="infobox"><?php echo $lang->sprintf($lang->archive_note, $fullurl); ?></div>
  76  <div id="content">
  77  <?php
  78      $sent_header = 1;
  79  }
  80  
  81  /**
  82   * Build the archive navigation.
  83   *
  84   * @return string The build navigation
  85   */
  86  function archive_navigation()
  87  {
  88      global $navbits, $mybb, $lang;
  89  
  90      $navsep = " &gt; ";
  91      if(is_array($navbits))
  92      {
  93          reset($navbits);
  94          foreach($navbits as $key => $navbit)
  95          {
  96              if($navbits[$key+1])
  97              {
  98                  if($navbits[$key+2])
  99                  {
 100                      $sep = $navsep;
 101                  }
 102                  else
 103                  {
 104                      $sep = "";
 105                  }
 106                  $nav .= "<a href=\"".$navbit['url']."\">".$navbit['name']."</a>$sep";
 107              }
 108          }
 109      }
 110      $navsize = count($navbits);
 111      $navbit = $navbits[$navsize-1];
 112      if($nav)
 113      {
 114          $activesep = $navsep;
 115      }
 116      $nav .= $activesep.$navbit['name'];
 117  
 118      return $nav;
 119  }
 120  
 121  /**
 122   * Output multipage navigation.
 123   *
 124   * @param int The total number of items.
 125   * @param int The items per page.
 126   * @param int The current page.
 127   * @param string The URL base.
 128  */
 129  function archive_multipage($count, $perpage, $page, $url)
 130  {
 131      global $lang;
 132      if($count > $perpage)
 133      {
 134          $pages = $count / $perpage;
 135          $pages = ceil($pages);
 136  
 137          for($i = 1; $i <= $pages; ++$i)
 138          {
 139              if($i == $page)
 140              {
 141                  $mppage .= "<strong>$i</strong> ";
 142              }
 143              else
 144              {
 145                  $mppage .= "<a href=\"$url-$i.html\">$i</a> ";
 146              }
 147          }
 148          $multipage = "<div class=\"multipage\"><strong>".$lang->archive_pages."</strong> $mppage</div>";
 149          echo $multipage;
 150      }
 151  }
 152  
 153  /**
 154   * Output the archive footer.
 155   *
 156   */
 157  function archive_footer()
 158  {
 159      global $mybb, $lang, $db, $nav, $maintimer, $fulltitle, $fullurl, $sent_header;
 160      $totaltime = $maintimer->stop();
 161      if($mybb->settings['showvernum'] == 1)
 162      {
 163          $mybbversion = ' '.$mybb->version;
 164      }
 165      else
 166      {
 167          $mybbversion = "";
 168      }
 169  ?>
 170  </div>
 171  <div class="navigation"><?php echo $nav; ?></div>
 172  <div id="printinfo">
 173  <strong><?php echo $lang->archive_reference_urls; ?></strong>
 174  <ul>
 175  <li><strong><?php echo $mybb->settings['bbname']; ?>:</strong> <?php echo $mybb->settings['bburl']."/index.php"; ?></li>
 176  <?php if($fullurl != $mybb->settings['bburl']) { ?><li><strong><?php echo $fulltitle; ?>:</strong> <?php echo $fullurl; ?></li><?php } ?>
 177  </ul>
 178  </div>
 179  </div>
 180  <div id="footer">
 181  <?php echo $lang->powered_by; ?> <a href="http://mybb.com">MyBB</a><?php echo $mybbversion; ?>, &copy; 2002-<?php echo date("Y"); ?> <a href="http://mybb.com">MyBB Group</a>
 182  </div>
 183  </body>
 184  </html>
 185  <?php
 186  }
 187  
 188  /**
 189   * Output an archive error.
 190   *
 191   * @param string The error language string identifier.
 192   */
 193  function archive_error($error)
 194  {
 195      global $lang, $mybb, $sent_header;
 196      if(!$sent_header)
 197      {
 198          archive_header("", $mybb->settings['bbname'], $mybb->settings['bburl']."/index.php");
 199      }
 200  ?>
 201  <div class="error">
 202  <div class="header"><?php echo $lang->error; ?></div>
 203  <div class="message"><?php echo $error; ?></div>
 204  </div>
 205  <?php
 206      archive_footer();
 207      exit;
 208  }
 209  
 210  /**
 211   * Ouput a "no permission"page.
 212   */
 213  function archive_error_no_permission()
 214  {
 215      global $lang, $db, $session;
 216  
 217      $noperm_array = array (
 218          "nopermission" => '1',
 219          "location1" => 0,
 220          "location2" => 0
 221      );
 222  
 223      $db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
 224  
 225      archive_error($lang->archive_nopermission);
 226  }
 227  
 228  /**
 229   * Check the password given on a certain forum for validity
 230   *
 231   * @param int The forum ID
 232   * @param boolean The Parent ID
 233   */
 234  function check_forum_password_archive($fid, $pid=0)
 235  {
 236      global $forum_cache;
 237      
 238      if(!is_array($forum_cache))
 239      {
 240          $forum_cache = cache_forums();
 241          if(!$forum_cache)
 242          {
 243              return false;
 244          }
 245      }
 246  
 247      // Loop through each of parent forums to ensure we have a password for them too
 248      $parents = explode(',', $forum_cache[$fid]['parentlist']);
 249      rsort($parents);
 250      if(!empty($parents))
 251      {
 252          foreach($parents as $parent_id)
 253          {
 254              if($parent_id == $fid || $parent_id == $pid)
 255              {
 256                  continue;
 257              }
 258              
 259              if($forum_cache[$parent_id]['password'] != "")
 260              {
 261                  check_forum_password_archive($parent_id, $fid);
 262              }
 263          }
 264      }
 265      
 266      $password = $forum_cache[$fid]['password'];
 267      if($password)
 268      {
 269          if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))
 270          {
 271              archive_error_no_permission();
 272          }
 273      }
 274  }
 275  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1