Viewing file: class.log.php (3.63 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php // depende de conn.php //include("../frames/conn.php"); // depende de conn.php include("../frames/conn.php"); echo BBDDUSER."<br> "; class control {
public $idbook=0; public $usuario=""; public $grupo=""; public $actividad=""; public $ip=""; public $fecha=""; public $titulo=""; public $autor=""; public $file="./log/log.log"; public $descargado; public $limite_descargas; public $descargas_pendientes; public $cookiename="phpbb3_ver2_sid"; public $bbdduser=BBDDUSER;
public $debug=true; var $sql=""; var $res; var $logconn;
public function __construct() { echo $this->bbdduser."<br> "; $this->fecha=date("Y-m-d H:i:s"); echo "-----".$bbdduser."+++++"; $this->logconn=mysql_connect("localhost",$bbdduser,$bbddpassword); $this->ip(); $this->busca_usuario(); if ($debug)print_r($this); }
function grabar() { $this->sql="insert $bbdd.estadistica (id_book, fecha, ip , titulo, autor, accion, nick) values(".$this->idbook."','".$this->fecha."','". $this->realip."','". $this->titulo."','". $this->autor."','". $this->actividad."','". $this->usuario."' )"; mysql_query($this->sql,$this->logconn);
}
function ip() { if ($_SERVER) { $this->ip = $_SERVER["REMOTE_ADDR"];
} else {
$this->ip = getenv( 'REMOTE_ADDR' );
} }
function busca_id() { $this->sql="select * from $bbdd.libros where id='".$this->idbook."'";
$this->res=mysql_query($this->sql,$this->logconn); echo mysql_error(); $row=mysql_fetch_array($this->res); $this->titulo=$row['titulo']; $this->autor=$row['autor']; }
function busca_usuario() { $this->sql="SELECT t1.session_user_id, t2.username_clean as usuario FROM $bbdduser_phpbb.phpbb_sessions t1, $bbdduser_phpbb.phpbb_users t2 WHERE t1.session_user_id = t2.user_id AND t1.session_id = '".$_REQUEST['phpbb3_ver2_sid']."'";
$this->res=mysql_query($this->sql,$this->logconn); echo mysql_error(); @$row=mysql_fetch_array($this->res); //print_r($row); if ($row[session_user_id]==1 or !$row[session_user_id]){ // es anonimo $this->usuario="anonimo"; $this->grupo="anonimo"; // query de control de bajada $this->sql="SELECT ip, count(ip) AS contador FROM $bbdd.estadistica where date(fecha) = curdate() and ip='{$this->ip}' and accion='descarga' group by (ip) order by count(ip) desc"; $res2=mysql_query($this->sql,$this->logconn); @ $row2=mysql_fetch_array($res2);
$this->descargado=$row2['contador']; }else{ // usuario registrado $this->usuario=$row['usuario'];
// buscamos el grupo. si no se encuentra, es normal $this->sql="SELECT t1.usuario,t1.grupo, t2.limite FROM $bbdd.control_usuarios as t1, $bbdd.limites_usuarios as t2 WHERE t1.grupo=t2.grupo and t1.usuario='".$this->usuario."'";
$res2=mysql_query($this->sql,$this->logconn); @ $row2=mysql_fetch_array($res2); // sacamos lo descargado por el usuario $this->sql="SELECT nick, count(nick) AS contador FROM $bbdd.estadistica where date(fecha) = curdate() and nick='".$this->usuario."' and accion='descarga' group by nick "; $this->res=mysql_query($this->sql,$this->logconn);
@$rowcontrol=mysql_fetch_array($this->res);
$this->descargado=$rowcontrol['contador'];
if (empty($row2['grupo'])){ // no se encuentra $this->grupo="normal"; }else{ // es colaborador o administrador $this->grupo=$row2['grupo']; }
} $this->sql="select limite from $bbdd.limites_usuarios where grupo='".$this->grupo."'";
$resv=mysql_query($this->sql,$this->logconn); @ $rowv=mysql_fetch_array($resv);
$this->limite_descargas=$rowv['limite']; $this->descargas_pendientes=$this->limite_descargas-$this->descargado ; }
}
|