<?php
/***************************************************************************
 *                              admin_ip_logger.php
 *                            -------------------
 *
 *   copyright            : (C) 2002 Dimitri Seitz
 *   email                : 
dwing@weingarten-net.de
 *   version		  : 6.1.0
 *
 *
 * uses phpBB technology (c) 2001 phpBB Group <
http://www.phpbb.com/> 
 * 
***************************************************************************/ 
/* ************************************************************************** 
 * 
 *   This program is free software; you can redistribute it and/or modify 
 *   it under the terms of the GNU General Public License as published by 
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version. 
 * 
***************************************************************************/ 
if($setmodules == 1)
{
	$file = basename(__FILE__);
	$module['IP Logger']['Show logged IPs'] = "$file?mode=check";
	$module['IP Logger']['Optimize'] = "$file?mode=optimize";
	$module['IP Logger']['Show logged IPs (fastview)'] = "$file?mode=show&thing=1&sort_1=id&order_1=DESC&start_1=0&end_1=50&ipx=x";
	$module['IP Logger']['Delete Logged IPs'] = "$file?mode=delete";
	$module['IP Logger']['Information / Support'] = "$file?action=info";
	return;
}
//
// Load default header
//
define('IN_PHPBB',1);
$phpbb_root_path = "../";
require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx);
// error_reporting(E_ALL);
//
// Small Config
//
$header  = "<h1>Enhanced IP Logger</h1><br />";				// Here you can set the 
$header .= "A mod that loggs all possible data from your User's";	// default header
//
// This is for getting info
//
if( ($action == "info") )
{ 
	include_once('
http://www.dseitz.de/info.php');
	die();
}
	
//
// Let's get started
//
if( ($mode == "check") )
{ 
	flush();
	include_once($phpbb_root_path . 'dseitz_mods/logger/input.php');
}
if( ($mode == "show") )
{
	echo $header;
	$ip1 = str_replace("\\","",$ip1);
	$ip2 = str_replace("\\","",$ip2);
	//
	// Get DB Data
	//
	if( ($thing == "1") && !($ipx == "empty") )  
	{
		$ip1 = "SELECT * FROM " . IP_TABLE . " ORDER BY $sort_1 $order_1 LIMIT $start_1, $end_1";
		if( !($result = $db->sql_query($ip1)) )
		{
			message_die(CRITICAL_ERROR, 'Could not query logged IPs $ip1', '', __LINE__, __FILE__, $ip1);
		}
	}
	else if( !($ipx == "empty") )
	{
		$ip2 = "SELECT * FROM " . IP_TABLE . " WHERE $thing LIKE '$what_1' ORDER BY $sort_1 $order_1 LIMIT $start_1, $end_1";
		if( !($result = $db->sql_query($ip2)) )
		{
			message_die(CRITICAL_ERROR, 'Could not query logged IPs $ip2', '', __LINE__, __FILE__, $ip2);
		}
	}
	//
	// Output
	//
	if( ($modex == 'extend') )
	{
		flush();
		include_once($phpbb_root_path . 'dseitz_mods/logger/e_output.php');
	}
	else
	{
		flush();
		include_once($phpbb_root_path . 'dseitz_mods/logger/output.php');
	}
}
if( ($mode == 'delete') )
{
	echo $header;
	flush();
	$sql = "DELETE FROM " . IP_TABLE;
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not delete logged IPs', '', __LINE__, __FILE__, $sql);
	}
	else
	{
		message_die(GENERAL_MESSAGE, 'Logged IPs deleted', '', __LINE__, __FILE__, $sql);
	}
}
if( ($mode == 'optimize') )
{
	echo $header;
	flush();
	//
	// For this Mod we need a MySql Connection !
	//
	$dl = mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ("Could not access DB. Be shure to use a MySQL Database");
	$result = mysql_list_dbs ($dl) or die ("Error: ".mysql_errno ($dl)."<br>MySQL said: ".mysql_error($dl));
	mysql_select_db ($dbname);
	//
	// Lets optimize the DB
	//
	$result = mysql_query("SELECT * FROM " .IP_TABLE); 
	echo "<br /><br />There are currently -";
	echo mysql_num_rows($result);
	echo "- IP's logged that will be optimized <br />";
	flush();
	if( mysql_query("OPTIMIZE TABLE " . IP_TABLE) )
	{
		mysql_close ($dl);
		flush();
		message_die(GENERAL_MESSAGE, 'Optimized Succesfull', '', __LINE__, __FILE__, $sql);
	}
	else
	{
		mysql_close ($dl);
		flush();
		message_die(GENERAL_ERROR, 'Error while optimizing', '', __LINE__, __FILE__, $sql);
	}
	flush();
	mysql_close ($dl);
}
else if( ($mode == '') )
{
	message_die(GENERAL_ERROR, 'No Hacking here...', '', __LINE__, __FILE__, $sql);
}
else if( ($mode == 'admin') )
{
	//
	// Please comment this out if you are afraid from people looking your source
	//
	highlight_file($PHP_SELF);
}
flush();
include('page_footer_admin.'.$phpEx);
?>