UserOnline/copy_this/core/d3usersonline.php

90 lines
2.9 KiB
PHP
Raw Normal View History

2011-10-19 22:05:36 +02:00
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Aggrosoft, D<EFBFBD> Data Development
*/
2011-10-19 22:53:23 +02:00
class d3usersonline extends oxI18n
2011-10-19 22:05:36 +02:00
{
/**
* Object core table name
*
* @var string
*/
2011-10-19 22:53:23 +02:00
protected $_sCoreTbl = 'd3usersonline';
2011-10-19 22:05:36 +02:00
/**
* Current class name
*
* @var string
*/
2011-10-19 22:53:23 +02:00
protected $_sClassName = 'd3usersonline';
2011-10-19 22:05:36 +02:00
public function __construct($aParams = null)
{
parent::__construct();
2011-10-19 22:53:23 +02:00
$this->init( 'd3usersonline' );
2011-10-19 22:05:36 +02:00
}
public function clearOldItems($iExpTime)
{
$exptime = time() - $iExpTime;
2011-10-19 22:53:23 +02:00
oxDb::getDb()->Execute("delete from ".$this->getViewName()." where timevisit < $exptime");
2011-10-19 22:05:36 +02:00
}
public function getActUserItem($sUserIPHash)
{
2011-10-19 22:53:23 +02:00
$sSelect = "select count(*) from ".$this->getViewName()." where visitor= ".oxDb::getDb()->quote($sUserIPHash);
2011-10-19 22:05:36 +02:00
return oxDb::getDb()->getOne( $sSelect );
}
public function getUserCount()
{
2011-10-20 22:03:48 +02:00
$sSelect = "select count(*) counter, oxclass from ".$this->getViewName()." GROUP BY oxclass ORDER BY counter desc";
2012-04-24 15:43:56 +02:00
$rs = oxDb::getDb(2)->Execute($sSelect);
2011-10-20 22:03:48 +02:00
$iAllCounter = 0;
$aUserClasses = array();
if ($rs != false && $rs->RecordCount() > 0)
{
while (!$rs->EOF)
{
$oTmp = new stdClass;
$oTmp->classname = $rs->fields['oxclass'];
$oTmp->counter = $rs->fields['counter'];
$iAllCounter += $rs->fields['counter'];
$aUserClasses['classes'][] = $oTmp;
$rs->moveNext();
}
}
$aUserClasses['all'] = $iAllCounter;
return $aUserClasses;
2011-10-19 22:05:36 +02:00
}
public function setActTimeVisit($sUserIpHash)
{
2011-10-19 22:53:23 +02:00
oxDb::getDb()->Execute("update ".$this->getViewName()." set timevisit= ".oxDb::getDb()->quote(time()).", oxclass = ".oxDb::getDb()->quote($this->getConfig()->getActiveView()->getClassName())." where visitor= ".oxDb::getDb()->quote($sUserIpHash));
2011-10-19 22:05:36 +02:00
}
public function insertActUser($sUserIpHash)
{
2011-10-19 22:53:23 +02:00
oxDb::getDb()->Execute("insert into ".$this->getViewName()." (visitor,timevisit,oxclass) values (".oxDb::getDb()->quote($sUserIpHash).", ".oxDb::getDb()->quote(time()).", ".oxDb::getDb()->quote($this->getConfig()->getActiveView()->getClassName()).")");
2011-10-19 22:05:36 +02:00
}
}