Вход Регистрация
Файл: include/log.php
Строк: 74
<?php

include_once("table_name.php");
include_once(
"base.php");

/**
    class for work with log players
*/

class CLogPlayers extends CBase
{

    var 
$uuid_log;
    var 
$table_storage;

    
/**
        Constructor
    */
    
function CLogPlayers($database,$vnum=0,$uuid_log=0)
    {
        
$this->db=$database;
        
$this->table_name=$GLOBALS['table_logs_players'];
        
$this->table_storage=$GLOBALS['table_logs_storage'];
        
$this->vnum=$vnum;
        
$this->uuid_log=$uuid_log;
    }

    
/**
        add log messages
    */
    
function addLogMsg($msg,$v0="")
    {
        
$t=time();

        
$sql "insert into $this->table_name(vnum,pdate,uuid_log,text,v0)".
        
"values ('$this->vnum','$t','$this->uuid_log','$msg','$v0')";

        
$result=$this->execSQL($sql);

    }
    
    
/**
        get all log message for current messages
    */
    
function getLogMsgs($sort_order='desc')
    {
        
$sql "select pdate,text from $this->table_name where vnum='$this->vnum' and uuid_log='$this->uuid_log' order by pdate $sort_order";
        
        
$result=$this->execSQL($sql);
        
        
$msgs = array();

        while(
$row $result->fetchRow())
        {
            
$msgs[] = array("pdate" => $row[0], "text" => str_replace("<br>","",$row[1]));
        }
        
        return 
$msgs;
    }
    
    
/**
        Get log start time 
    */
    
function getFirstLogTime()
    {
        
$sql "select pdate from $this->table_name where vnum='$this->vnum' and uuid_log='$this->uuid_log' order by pdate limits 1";
        
        
$result=$this->execSQL($sql);
        
        if(
$result->numRows()==0) return 0;

        
$row $result->fetchRow();
        
        return 
$row[0];
    }
    
    
/**
        Get log last time 
    */
    
function getLastLogTime()
    {
        
$sql "select pdate from $this->table_name where vnum='$this->vnum' and uuid_log='$this->uuid_log' order by pdate desc limits 1";
        
        
$result=$this->execSQL($sql);
        
        if(
$result->numRows()==0) return 0;

        
$row $result->fetchRow();
        
        return 
$row[0];
    }
    
    
/**
        Get time diff start and last time log
    */
    
function getContinueLogs()
    {
        
$time_begin=$this->getFirstLogTime();
        
$time_end=$this->getLastLogTime();
        
        
$time_cont=$time_end-$time_begin;
        
$m intval(date("i",$time_cont));
        
        return 
$m;
    }
    
    
/**
        add typing log messages
    */
    
function addTypeLogMsg($type,$msg)
    {
        
$t=time();
        
        
$sql "insert into $this->table_storage(vnum,pdate,type,text)".
        
"values ('$this->vnum','$t','$type','$msg')";

        
$result=$this->execSQL($sql);
    }
    
    
/**
        get typing log messages
    */
    
function getLogTypeMsgs($type)
    {
        
$sql "select pdate,text from $this->table_storage where vnum='$this->vnum' and type='$type' order by pdate desc";
        
        
$result=$this->execSQL($sql);
        
        
$msgs = array();

        while(
$row $result->fetchRow())
        {
            
$msgs[] = array("pdate" => getDates($row[0])." ".getTimes($row[0]), "text" => $row[1]);
        }
        
        return 
$msgs;
    }
}

?>
Онлайн: 0
Реклама