Backing up IP banlist

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
Kajin
Registered User
Posts: 112
Joined: Wed Jun 15, 2005 5:06 am
Location: Moonside
Contact:

Backing up IP banlist

Post by Kajin »

Is there a way to back up the IP banlist as a viewable text document so I can manually re-input them on an invision forum or a VB forum?
Image
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

Not by default, but i'll see if i can code something for you ;)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

Okay, i made a mod. This is based on oxpus "download posts and topics" MOD.

OPEN:

Code: Select all

language/lang_english/lang_admin.php
FIND:

Code: Select all

//
// That's all Folks!
BEFORE, ADD:

Code: Select all

$lang['Banned_ip_list'] = 'List of banned IPs';
OPEN:

Code: Select all

admin/admin_user_ban.php
FIND:

Code: Select all

'L_FIND_USERNAME' => $lang['Find_username'],
AFTER, ADD:

Code: Select all

		'L_BANNED_LIST' => $lang['Banned_ip_list'],
		'U_BANNED_LIST' => append_sid("admin_ban_ip_list.$phpEx"),
OPEN:

Code: Select all

templates/subSilver/admin/user_ban_body.tpl
FIND:

Code: Select all

{L_UNBAN_IP_EXPLAIN}
INLINE FIND:

Code: Select all

{L_UNBAN_IP_EXPLAIN}
INLINE AFTER, ADD:

Code: Select all

<br /><a href="{U_BANNED_LIST}">{L_BANNED_LIST}</a>
COPY:

Code: Select all

copy admin_ban_ip_list.php to admin/admin_ban_ip_list.php
Here's the source of that file:

Code: Select all

<?php
/***************************************************************************
 *                            admin_ban_ip_list.php
 *                            -------------------
 *   begin                : Friday, Jun 16, 2006
 *   copyright            : (C) 2001 The phpBB Group & eviL<3
 *   email                : evil@ut4e.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.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

//
// Load default header
//
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');
$no_page_header = 1;
require('./pagestart.' . $phpEx);


//
// Get all IPs from the Ban table
//
$sql = "SELECT ban_ip
	FROM " . BANLIST_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not select current ip ban list', '', __LINE__, __FILE__, $sql);
}

$banlist = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);


//
// Check if Banlist is empty
//
if( count($banlist) == 0 )
{
	die(sux);
}
else
{
	for($i = 0; $i < count($banlist); $i++)
	{
		// Thanks to oxpus for this part
		$ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
		$select_iplist = $ban_ip;
	
		$message = $ban_ip;
		$break = "\n";
		$download_file .= $message.$break;
	}

	$filename = 'iplist_'.date("Ymd",time()).'.txt';
	header('Content-Type: text/x-delimtext; name="'.$filename.'"');
	header('Content-Disposition: attachment;filename="'.$filename.'"');
	header('Content-Transfer-Encoding: plain/text');
	header('Content-Length: '.strlen($download_file));
	print $download_file;

	exit;
}

?>
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
Kajin
Registered User
Posts: 112
Joined: Wed Jun 15, 2005 5:06 am
Location: Moonside
Contact:

Post by Kajin »

my CP now says

Code: Select all

Fatal error: Cannot redeclare class template in /home/.taj/themys2/phpmyadmin.themysticalforestzone.com/phpBB2/includes/template.php on line 30
:cry:

Problem seemed to go away only when I deleted admin_ban_ip_list.php
Last edited by Kajin on Fri Jun 16, 2006 5:39 am, edited 1 time in total.
Image
User avatar
karlsemple
Former Team Member
Posts: 39802
Joined: Mon Nov 01, 2004 8:54 am
Location: Hereford, UK
Contact:

Post by karlsemple »

why not just back the phpbb_banlist database table up into a sql file in phpmyadmin ???
Image
Kajin
Registered User
Posts: 112
Joined: Wed Jun 15, 2005 5:06 am
Location: Moonside
Contact:

Post by Kajin »

karlsemple wrote: why not just back the phpbb_banlist database table up into a sql file in phpmyadmin ???
IPs are unreadable. They're in hexidecimal code or something...
Image
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

It's not working for me either, i'm having a look into it ;)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

UPDATE:


OPEN:

Code: Select all

admin/admin_user_ban.php
FIND:

Code: Select all

'U_BANNED_LIST' => append_sid("admin_ban_ip_list.$phpEx"),
REPLACE, WITH:

Code: Select all

'U_BANNED_LIST' => append_sid("ban_ip_list.$phpEx"),

COPY:

Code: Select all

copy ban_ip_list.php to admin/ban_ip_list.php
Here's the source of that file:

Code: Select all

<?php
/***************************************************************************
 *                            ban_ip_list.php
 *                            -------------------
 *   begin                : Friday, Jun 16, 2006
 *   copyright            : (C) 2001 The phpBB Group & eviL<3
 *   email                : evil@ut4e.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.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

//
// Load default header
//
$no_page_header = TRUE;
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);


//
// Get all IPs from the Ban table
//
$sql = "SELECT ban_ip
   FROM " . BANLIST_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not select current ip ban list', '', __LINE__, __FILE__, $sql);
}

$banlist = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);


//
// Check if Banlist is empty
//
if( count($banlist) == 0 )
{
   message_die(GENERAL_MESSAGE, $lang['No_banned_ip']);
}
else
{
   for($i = 0; $i < count($banlist); $i++)
   {
      // Thanks to oxpus for this part
      $ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
      $select_iplist = $ban_ip;
   
      $message = $ban_ip;
      $break = "\n";
      $download_file .= $message.$break;
   }

   $filename = 'iplist_'.date("Ymd",time()).'.txt';
   header('Content-Type: text/x-delimtext; name="'.$filename.'"');
   header('Content-Disposition: attachment;filename="'.$filename.'"');
   header('Content-Transfer-Encoding: plain/text');
   header('Content-Length: '.strlen($download_file));
   print $download_file;

   exit;
}

?>

Note: The file + the filename have changed. ;)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
Kajin
Registered User
Posts: 112
Joined: Wed Jun 15, 2005 5:06 am
Location: Moonside
Contact:

Post by Kajin »

Though the first few hundred rows of the text file showed up as "0.0.0.0", the rest was the exact list I needed! Thank you SO much!! :D

You should seriously submit this as a mod!
Image
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

Kajin wrote: Though the first few hundred rows of the text file showed up as "0.0.0.0", the rest was the exact list I needed! Thank you SO much!! :D

You should seriously submit this as a mod!


Look in the "Mods in devolepment" forum ;)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
Locked

Return to “2.0.x Support Forum”