[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/inc/ -> functions_warnings.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: functions_warnings.php 5297 2010-12-28 22:01:14Z Tomm $
  10   */
  11  
  12  /**
  13   * Returns a friendly expiration time of a suspension/warning
  14   *
  15   * @param int The time period of the suspension/warning
  16   * @return array An array of the time/period remaining
  17   */
  18  function fetch_friendly_expiration($time)
  19  {
  20      if($time == 0 || $time == -1)
  21      {
  22          return array("period" => "never");
  23      }
  24      else if($time % 2592000 == 0)
  25      {
  26          return array("time" => $time/2592000, "period" => "months");
  27      }
  28      else if($time % 604800 == 0)
  29      {
  30          return array("time" => $time/604800, "period" => "weeks");
  31      }
  32      else if($time % 86400 == 0)
  33      {
  34          return array("time" => $time/86400, "period" => "days");
  35      }
  36      else
  37      {
  38          return array("time" => ceil($time/3600), "period" => "hours");
  39      }
  40  }
  41  
  42  /**
  43   * Figures out the length of a suspension/warning
  44   *
  45   * @param int The amount of time to calculate the length of suspension/warning
  46   * @param string The period of time to calculate the length of suspension/warning
  47   * @return int Length of the suspension/warning (in seconds)
  48   */
  49  function fetch_time_length($time, $period)
  50  {
  51      $time = intval($time);        
  52  
  53      if($period == "hours")
  54      {
  55          $time = $time*3600;
  56      }
  57      else if($period == "days")
  58      {
  59          $time = $time*86400;
  60      }
  61      else if($period == "weeks")
  62      {
  63          $time = $time*604800;
  64      }
  65      else if($period == "months")
  66      {
  67          $time = $time*2592000;
  68      }
  69      else if($period == "never" && $time == 0)
  70      {
  71          // User is permanentely banned
  72          $time = "-1";
  73      }
  74      else
  75      {
  76          $time = 0;
  77      }
  78      return $time;
  79  }
  80  ?>


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