Viewing file: class.log_mini.php (3.74 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php // depende de conn.php
//include("../frames/conn.php");
// depende de 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 $basedatos="";
public $baselibros="";
public $dia;
public $total=false;
public $pais;
public $debug=false;
var $sql="";
var $res;
var $logconn;
var $conremote;
public function __construct($bbdduser=BBDDUSER,$bbddpassword=BBDDPASSWORD,$bbdd=BBDD_FORO,$bbddlibros=BBDD)
{
$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();
if ($this->debug)print_r($this);
}
function grabar()
{
$this->sql="insert {$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()
{
// la mcookie se genera en foro.papyrefb2.net /phpbb3/includes/function/function (page_header)
$this->usuario="anonymous";
if(isset($_COOKIE['phpbb3_gro']) and strtoupper($_COOKIE['phpbb3_gro'])!="ANONYMOUS" and intval($_COOKIE['phpbb3_gro'])!=0 ){
$this->usuario=$_COOKIE['phpbb3_gro'];
}else{
$conremote=mysql_connect("localhost",'papyr225_phpb1','bJ8V1vmDPkHZ');
$sql_remote="select t1.session_id , t1.session_user_id,t2.username_clean from papyr225_phpb1.phpbb_sessions as t1, papyr225_phpb1.phpbb_users as t2 where t1.session_id='".$_COOKIE['phpbb3_ver2_sid']."' and t1.session_user_id=t2.user_id";
$res=mysql_query($sql_remote,$conremote);
$row=mysql_fetch_array($res);
$this->usuario=$row['username_clean'];
setcookie("phpbb3_gro",$this->usuario,time()+60*60*24,'/','papyrefb2.net');
}
if ($this->usuario=='anonymous' or $this->usuario=='Anonymous' or $this->usuario=="")$this->usuario='anonimo';
}
// fin funcion
} // fin clase
|