HEX
Server: Apache
System: Linux iad1-shared-e1-19 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User: austral3d (14892361)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /home/austral3d/fourdplan.com/webservices_0_4_20/reporteSesion.php
<?php
    require_once("comun/conexion_mysqli.php");
$db = fdp_connect();

date_default_timezone_set('America/Santiago');	

$to  = 'daniel@austral3d.com, francisco@austral3d.com, nd0806@gmail.com, tecnologia@austral3d.com';
$subject = 'Reporte semanal de ingresos a Fourdplan y Avit Mining';
$today = date('Y-m-d');
$start_date = date('Y-m-d', strtotime($today. ' - 7 days'));


$header1 = '<tr>
					<th>Mail</th>
					<th>nombre</th>
					<th>apellido</th>
					<th>ingreso</th>
					<th>IP</th>
					<th>empresa</th>
					<th>tipo</th>
				<tr>';
				
$header2 = '<tr>
					<th>Mail</th>
					<th>nombre</th>
					<th>apellido</th>
					<th>ingreso</th>
					<th>IP</th>
				<tr>';				
				
$header3 = $header2;
$header4 = $header2;

$header5 = '<tr>
					<th>Mail</th>
					<th>ingreso</th>
					<th>IP</th>
					<th>demo</th>
				<tr>';

$header6 = '<tr>
					<th>email</th>
					<th>nombre</th>
					<th>apellido</th>		
					<th>pais</th>
					<th>telefono</th>
					<th>empresa</th>
				<tr>';

$header7 = $header2;
$header8 = $header2;		
$header9 = $header2;

function fetch_table_data($db, $sql_data, &$header, &$table) {
	$data = fdp_query_all($db, $sql_data);

	if(sizeof($data) == 0) {
		$header = "";
		$tabla = "No hay ingresos";
	}
	else {
		foreach ($data as $key => $tupla)
		{	
			$tabla .= "<tr>";
			foreach ($tupla as $key => $columna) {
				$tabla .= "<td>" . $columna . "</td>";
			}
			$tabla .= "</tr>";
		}
	}
}

$sql_data = "
	SELECT u.mail, u.nombre, u.apellido, s.inicio, s.ip, e.nombre, sof.software
	FROM Usuario u, Sesion s, Empresa e, Software sof
	WHERE s.id_usuario = u.id
	AND e.id = u.id_empresa
	AND s.id_software = sof.id
	AND s.inicio >= '$start_date'
	AND id_usuario != 1
	ORDER BY s.inicio DESC";
$tabla1 = "";
fetch_table_data($db, $sql_data, $header1, $tabla1);

mysqli_select_db($db, 'avit_elec');

$sql_data = "
	SELECT email, tiempo, ip, demo
	FROM LoginDemos
	WHERE tiempo >= '$start_date'
	ORDER BY tiempo DESC";
$tabla5 = "";
fetch_table_data($db, $sql_data, $header5, $tabla6);

$sql_data = "
	SELECT email, nombre, apellido, pais, telefono, empresa
	FROM UsuarioPagina
	ORDER BY id
	DESC LIMIT 10";
$tabla6 = "";
fetch_table_data($db, $sql_data, $header6, $tabla6);

mysqli_select_db($db, 'avit_cl');

$sql_data = "
	SELECT u.mail, u.nombres, u.apellido_paterno, s.tiempo_inicio, s.ip
	FROM Usuario u, Sesion s
	WHERE s.id_usuario = u.id
		AND s.tiempo_inicio >= '$start_date'
		AND id_usuario != 1
		AND id_usuario != 2
	ORDER BY s.tiempo_inicio DESC";
$tabla7 = "";
fetch_table_data($db, $sql_data, $header7, $tabla7);

mysqli_select_db($db, 'kaufmann');

$sql_data = "
	SELECT u.mail, u.nombre, u.apellido, s.inicio, s.ip
	FROM Usuario u, Sesion s
	WHERE s.id_usuario = u.id
		AND s.inicio >= '$start_date'
		AND id_usuario != 1
	ORDER BY s.inicio DESC";
$tabla8 = "";
fetch_table_data($db, $sql_data, $header8, $tabla8);

mysqli_select_db($db, 'falck');

$sql_data = "
	SELECT u.mail, u.nombre, u.apellido, s.inicio, s.ip
	FROM Usuario u, Sesion s
	WHERE s.id_usuario = u.id
		AND s.inicio >= '$start_date'
		AND id_usuario != 1
	ORDER BY s.inicio DESC";
$tabla9 = "";
fetch_table_data($db, $sql_data, $header9, $tabla9);

// $message = '
// <html>
// <head>
// </head>
// <body>  
// 	<div>
// 		<center>
// 			<img src="http://www.fourdplan.com/webservices/banner2.jpg" height="107" width="765">
// 			<br style = "color: white;">.</br>
// 			<table style="width:100%;">
// 				<tr>
// 					<th style = "border: 1px solid black;">FOURDPLAN</th>
// 					<th style = "border: 1px solid black; font-size:22px;">Reporte semanal de ingresos a Fourdplan y Avit Mining</th> 
// 					<th style = "border: 1px solid black;">AUSTRAL3D</th>
// 				</tr>
// 			</table>
			
// 			<table style="width:100%;">
// 				<tr>
// 					<td style = "border: 1px solid black; font-weight: bold;">Desde:</td>
// 					<td style = "border: 1px solid black;">' . $start_date . '</td>
// 					<td style = "border: 1px solid black; font-weight: bold;">Hasta:</td>
// 					<td style = "border: 1px solid black;">' . $today . '</td>
// 				</tr>
// 				<tr>
// 					<td colspan="4" style = "border: 1px solid black;"><center>Se excluye al administrador</center></td>
// 				</tr>
// 			</table>
			
// 			<br>
			
// 			<p><b>FOURDPLAN</b></p>
// 			<table border="1">'
// 				. $header1 . $tabla1 . 
// 			'</table>
			
// 			<p><b>AUSTRAL3D DEMOS</b></p>
// 			<table border="1">'
// 				. $header5 . $tabla5 . 
// 			'</table>
			
// 			<p><b>AUSTRAL3D REGISTRO DE USUARIOS</b></p>
// 			<p>Como no hay registro de fechas se muestran las ultimas 10 filas.</p>
// 			<table border="1">'
// 				. $header6 . $tabla6 . 
// 			'</table>
			
// 			<p><b>CRYSTAL LAGOONS</b></p>
// 			<table border="1">'
// 				. $header7 . $tabla7 . 
// 			'</table>
			
// 			<p><b>KAUFMANN</b></p>
// 			<table border="1">'
// 				. $header8 . $tabla8 . 
// 			'</table>
			
// 			<p><b>FALCK</b></p>
// 			<table border="1">'
// 				. $header9 . $tabla9 . 
// 			'</table>
		
// 		</center>;
			
		
	
// 	</div>
  
// </body>
// </html>';

// $headers  = 'MIME-Version: 1.0' . "\r\n";
// $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// $headers .= 'From: Austral3D <tecnologia@austral3d.com>' . "\r\n";

// $mail_sent = mail($to, $subject, $message, $headers);

 ?>