Viewing file: class.log.php (10.16 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");
include("/home/wwwroot/frames/conexion/conn.php");
error_reporting(E_ALL ^ E_NOTICE);
date_default_timezone_set('Europe/Madrid');
function microtime_float()
{
list($useg, $seg) = explode(" ", microtime());
return ((float)$useg + (float)$seg);
}
class control
{
public $idbook=0;
public $usuario="";
public $grupo="";
public $subgrupo=false;
public $sinopsis_aut=false;
public $actividad="";
public $ip="";
public $fecha="";
public $fecha_patro="";
public $titulo="";
public $autor="";
public $file="./log/log.log";
public $descargado;
public $descargadoanonimo;
public $limite_descargas;
public $descargas_pendientes;
public $cookiename="phpbb3_nfhiu";
public $user;
public $password;
public $basedatos="";
public $baselibros="";
public $dia;
public $total=false;
public $pais;
public $pasando=false;
public $debug=false;
var $sql="";
var $res;
var $logconn;
var $conremote;
public function __construct($pasando,$bbdduser=BBDDUSER,$bbddpassword=BBDDPASSWORD,$bbdd=BBDD_FORO,$bbddlibros=BBDD)
{
//print_r($this);
$this->pasando=$pasando;
$this->basedatos=$bbdd;
$this->baselibros=$bbddlibros;
$date = new DateTime(date("Y-m-d H:i:s"));
$this->fecha=$date->format("Y-m-d H:i:s");
$this->dia=$date->format("Y-m-d");
#echo $date->format("Y-m-d");
//$this->fecha=date("Y-m-d H:i:s");
$this->logconn=mysql_connect("localhost",$bbdduser,$bbddpassword);
@$this->ip();
$this->busca_usuario($this->pasando);
if ($this->debug)print_r($this);
}
function grabar()
{
if ($this->actividad != "descarga"){
$this->sql="insert delayed into {$this->baselibros}.estadistica (id_book,
fecha, ip , titulo, autor, accion, nick,referer)
values(".$this->idbook."','".$this->fecha."','". $this->realip."','". $this->titulo."','". $this->autor."','".$this->actividad."','". $this->usuario."','".$_SERVER['HTTP_REFERER']."')";
mysql_query($this->sql,$this->logconn);
}
}
function ip()
{
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])){
if ($_SERVER["HTTP_X_FORWARDED_FOR"]>''){
$this->ip=$_SERVER["HTTP_X_FORWARDED_FOR"]."-".$_SERVER["HTTP_CF_CONNECTING_IP"];
}else{
$this->ip=$_SERVER["HTTP_CF_CONNECTING_IP"];
}
$this->pais=$_SERVER["HTTP_CF_IPCOUNTRY"];
}else{
if ($_SERVER) {
if ($_SERVER["HTTP_X_FORWARDED_FOR"]>''){
$this->ip = $_SERVER["HTTP_X_FORWARDED_FOR"]."-".$_SERVER["REMOTE_ADDR"];
}else{
$this->ip =$_SERVER["REMOTE_ADDR"];
}
} else {
$this->ip = getenv( 'REMOTE_ADDR' );
}
}
}
function busca_id()
{
$this->sql="select * from {$this->baselibros}.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()
{
// $conremote=mysql_connect("81.4.127.184",'papyr225_phpb1','bJ8V1vmDPkHZ');
// la mcookie se genera en foro.papyrefb2.net /phpbb3/includes/function/function (page_header)
if ($this->pasando) {
$this->usuario=$this->pasando;
}else{
if(isset($_COOKIE['phpbb3_gro'])){
@$var=$_COOKIE['phpbb3_gro'];
$var=str_replace('ª',"�",$var);
$var=str_replace('á',"�",$var);
$var=str_replace('é',"�",$var);
$var=str_replace('�',"�",$var);
$var=str_replace('��',"�",$var);
$var=str_replace('��',"�",$var);
$var=str_replace('��',"�",$var);
$var=str_replace('��',"�",$var);
$var=str_replace('��',"�",$var);
$this->usuario=$var;
}
}
//echo "----------------------------$this->pasando";
/*
if(isset($_COOKIE['phpbb3_mb']) and !isset($_COOKIE['phpbb3_gro']) and strlen($_cookie['phpbb3_gro']<20)){
$this->usuario=$_COOKIE['phpbb3_gro'];
}
*/
if ($this->usuario=='anonymous' or $this->usuario=="Anonymous" or $this->usuario=='0')$this->usuario='anonimo';
if($this->usuario=="")$this->usuario='anonimo';
// echo $_COOKIE['Phpbb3_gro'].$this->usuario;
if ($this->usuario=='anonimo'){
// es anonimo
$this->usuario="anonimo";
$this->grupo="anonimo";
$this->sql="SELECT ip, count(ip) AS contador FROM {$this->baselibros}.estadistica where date(fecha) ='{$this->dia}' and ip='{$this->ip}' and accion='descarga' group by (ip) order by count(ip) desc";
$res3=mysql_query($this->sql,$this->logconn);
@ $row3=mysql_fetch_array($res3);
//echo $this->sql;
$this->descargado=$this->descargado+$row3['contador'];
// echo "@".$this->descargado;
$this->descargas_pendientes=0;
}else{
// usuario registrado
// a�adido. Aqui vemos si el usuario esta autorizado a modificar las sinopsis
$this->sql="select usuario from {$this->baselibros}.control_sinopsis where usuario='{$this->usuario}'";
$ressinop=mysql_query($this->sql,$this->logconn);
@ $rowsinop=mysql_fetch_array($ressinop);
if ($rowsinop['usuario']>''){
$this->sinopsis_aut=true;
}
// buscamos el grupo. si no se encuentra, es normal
/*$this->sql="SELECT t1.usuario,t1.grupo,t1.subgrupo, t2.limite FROM {$this->baselibros}.control_usuarios as t1, {$this->baselibros}.limites_usuarios as t2 WHERE t1.grupo=t2.grupo and t1.usuario='".$this->usuario."'";
//echo $this->sql;
*/
$this->sql="SELECT t1.usuario,t1.grupo,t1.subgrupo, t2.limite, t3.fecha, t3.vitalicio FROM {$this->baselibros}.control_usuarios as t1
left join {$this->baselibros}.limites_usuarios t2
on t1.grupo = t2.grupo
left outer join {$this->baselibros}.patrocinadores t3
on t1.usuario = t3.usuario
where 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 {$this->baselibros}.estadistica where nick='".$this->usuario."' and accion='descarga' and date(fecha) ='{$this->dia}' group by nick ";
$this->res=mysql_query($this->sql,$this->logconn);
@$rowcontrol=mysql_fetch_array($this->res);
// y ahora, a�adimos la IP! ( por los listos de los cojones )
$this->sql="SELECT ip, count(ip) AS contador FROM {$this->baselibros}.estadistica where ip='{$this->ip}' and nick<>'{$this->usuario}' and date(fecha) ='{$this->dia}' and accion='descarga' group by (ip) order by count(ip) desc"; //81.47.192.162
$resd=mysql_query($this->sql,$this->logconn);
@ $rowd=mysql_fetch_array($resd);
$this->descargadomismaip=$rowd['contador'];
$this->descargado=$rowd['contador']+$rowcontrol['contador'];
$this->subgrupo=$row2['subgrupo'];
//----------------------meollo de la cuestion
if (empty($row2['grupo'])){
// no se encuentra,
// tralla
$this->grupo="registrado";
$this->total=false;
// torrebuno temporal!
// $dia = time()+(8*24*60*60); //Te suma 8 dias (7*24*60*60)
// $dia_fin = date('Y-m-d', $dia); //Formatea dia
// if (date('Y-m-d')< $dia_fin){
// $this->grupo="patrocinador";
// $this->total=true;
// }
// fin torrebruno temporal
}else{
/*
SELECT t1.usuario,t1.grupo,t1.subgrupo, t2.limite, t3.fecha, t3.vitalicio FROM control_usuarios as t1
left join limites_usuarios t2
on t1.grupo = t2.grupo
left outer join patrocinadores t3
on t1.usuario = t3.usuario
where t1.usuario='elendil'
*/
// es colaborador o administrador .
//O quizas no, vamos a ver la fecha ( solo en el caso de patrocinador normal, a los bibliotecarios ( subgrupo) los dejamos.
if ($row2['grupo']=="patrocinador" and $row2['subgrupo']<>"BIBLIOTECARIO" and $row2['vitalicio']==0 ){
// AHORA, que sabemos que es bibliotecario, miramos si ha pasado un a�ito.
$resultado = strtotime(date("Y-m-d"))-strtotime($row2['fecha']);
$dias = $resultado / 60 /60 /24;
if ($dias > 400){
$this->grupo="expatrocinador";
$this->total=false;
$this->fecha_patro=" caduc� el ";
$pepe=strtotime($row2['fecha']." +400 days");
$this->fecha_patro.=date("d-m-Y",$pepe);
}else{
$this->grupo="patrocinador";
$this->total=true;
$this->fecha_patro="valido hasta ";
$pepe=strtotime(date($row2['fecha'])." +400 days");
$this->fecha_patro.=date("d-m-Y",$pepe);
}
}ELSE{
// O ES BIBLIOTECARIO , vitalicio O M�S.
$this->grupo=$row2['grupo'];
$this->total=true;
}
}
$this->sql="select limite from {$this->baselibros}.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 ;
}
} // fin funcion
} // fin clase
|