stats
[ class tree: stats ] [ index: stats ] [ all elements ]

Source for file stats.inc.php

Documentation is available at stats.inc.php

  1. <?php
  2.     /**
  3.      * @author            Matthias Reuter ($LastChangedBy: matthias $)
  4.      * @version            $LastChangedDate: 2009-08-26 19:19:41 +0200 (Mi, 26 Aug 2009) $
  5.      * @package            stats
  6.      * @copyright        2007-2010 IPBWI development team
  7.      * @link            http://ipbwi.com/examples/stats.php
  8.      * @since            2.0
  9.      * @license            http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
  10.      */
  11.     class ipbwi_stats extends ipbwi {
  12.         private $ipbwi            null;
  13.         /**
  14.          * @desc            Loads and checks different vars when class is initiating
  15.          * @author            Matthias Reuter
  16.          * @since            2.0
  17.          * @ignore
  18.          */
  19.         public function __construct($ipbwi){
  20.             // loads common classes
  21.             $this->ipbwi $ipbwi;
  22.         }
  23.         /**
  24.          * @desc            Gets board statistics.
  25.          * @return    array    Board Statistics
  26.          * @author            Matthias Reuter
  27.          * @sample
  28.          *  <code>
  29.          *  $ipbwi->stats->board();
  30.          *  </code>
  31.          * @since            2.0
  32.          */
  33.         public function board(){
  34.             // Check for cache
  35.             if($cache $this->ipbwi->cache->get('statsBoard''1')){
  36.                 return $cache;
  37.             }else{
  38.                 $this->ipbwi->ips_wrapper->DB->query('SELECT cs_value FROM '.$this->ipbwi->board['sql_tbl_prefix'].'cache_store WHERE cs_key = "stats"');
  39.                 $row $this->ipbwi->ips_wrapper->DB->fetch();
  40.                 $stats unserialize(stripslashes($row['cs_value']));
  41.                 $this->ipbwi->cache->save('statsBoard'1$stats);
  42.                 return $stats;
  43.             }
  44.         }
  45.         /**
  46.          * @desc            Returns the active user count.
  47.          * @return    array    Active User Count
  48.          * @author            Matthias Reuter
  49.          * @sample
  50.          *  <code>
  51.          *  $ipbwi->stats->activeCount();
  52.          *  </code>
  53.          * @since            2.01
  54.          */
  55.          function activeCount({
  56.             if($cache $this->ipbwi->cache->get('activeCount''1')){
  57.                 return $cache;
  58.             }else{
  59.                 // Init
  60.                 $count array('total' => '0''anon' => '0''guests' => '0''members' => '0');
  61.                 $cutoff $this->ipbwi->ips_wrapper->vars['au_cutoff'$this->ipbwi->ips_wrapper->vars['au_cutoff''15';
  62.                 $timecutoff time(($cutoff 60);
  63.                 $this->ipbwi->ips_wrapper->DB->query('SELECT member_id, login_type FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions WHERE running_time > "'.$timecutoff.'"');
  64.                 // Let's cache so we don't screw ourselves over :)
  65.                 $cached array();
  66.                 // We need to make sure our man's in this count...
  67.                 if($this->ipbwi->member->isLoggedIn()){
  68.                     if(substr($this->ipbwi->member->myInfo['login_anonymous'],01== '1'){
  69.                         ++$count['anon'];
  70.                     }else{
  71.                         ++$count['members'];
  72.                     }
  73.                     $cached[$this->ipbwi->member->myInfo['member_id']] 1;
  74.                 }
  75.                 while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  76.                     // Add up members
  77.                     if($row['login_type'== '1' && !array_key_exists($row['member_id'],$cached)){
  78.                         ++$count['anon'];
  79.                         $cached[$row['member_id']] 1;
  80.                     }elseif($row['member_id'== '0'){
  81.                         ++$count['guests'];
  82.                     }elseif(!array_key_exists($row['member_id'],$cached)){
  83.                         ++$count['members'];
  84.                         $cached[$row['member_id']] 1;
  85.                     }
  86.                 }
  87.                 $count['total'$count['anon'$count['guests'$count['members'];
  88.                 $this->ipbwi->cache->save('activeCount''detail'$count);
  89.                 return $count;
  90.             }
  91.         }
  92.         /**
  93.          * @desc            Returns members born on the given day of a month.
  94.          * @param    int        $day Optional. Current day is used if left as an empty string or zero.
  95.          * @param    int        $month Optional. Current month is used if left as an empty string or zero.
  96.          * @return    array    Birthday Members
  97.          * @author            Matthias Reuter
  98.          * @sample
  99.          *  <code>
  100.          *  $ipbwi->stats->birthdayMembers();
  101.          *  $ipbwi->stats->birthdayMembers(22,7);
  102.          *  </code>
  103.          * @since            2.01
  104.          */
  105.         function birthdayMembers($day 0$month 0{
  106.             if((int)$day<=0){
  107.                 $day date('j');
  108.             }
  109.             if((int)$month<=0){
  110.                 $month date ('n');
  111.             }
  112.             $this->ipbwi->ips_wrapper->DB->query('SELECT m.*, me.signature, me.avatar_size, me.avatar_location, me.avatar_type, me.vdirs, me.location, me.msnname, me.interests, me.yahoo, me.website, me.aim_name, me.icq_number, g.*, cf.* FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members m LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'groups g ON (m.mgroup=g.g_id) LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'pfields_content cf ON (cf.member_id=m.id) LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'member_extra me ON (m.id=me.id) WHERE m.bday_day="'.intval($day).'" AND m.bday_month="'.intval($month).'"');
  113.             $return array();
  114.             $thisyear date ('Y');
  115.             while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  116.                 $row['age'$thisyear $row['bday_year'];
  117.                 $return[$row;
  118.             }
  119.             return $return;
  120.         }
  121.     }
  122. ?>

Documentation generated on Sat, 23 Oct 2010 23:36:12 +0200 by phpDocumentor 1.4.3