Database cleaner NEEDED

Subz

Seasoned Veteran
Joined
May 9, 2008
Messages
3,241
Reaction score
0
FP$
6
Hi Everyone, i have a database of my friends website, and bsically has been modded to hell -lol-

it has the 0.3.2 cash mod installed on the database, i have removed the cash mod tables and removed the queries in the config table but its no use as the cash mod still appears in the mod tb in ACP.

I want to remove it as i have instlled the simple points mod and i can't get any of the settings to show or be displyed and i think its because the cash mod is still in the database. there are othermods in the database too, so i would like to clean the database by removing all queries that mods have made.

I know there is one available for phpBB2 but i wouldered if anyone know of one that is on phpbb3?


here is the sql tables that the csh mod added

i am posting the db_update file as its esier to see and i my not miss anything out.

Code:
<?php
// -------------------------------------------------------------
//
// $Id: cash_db.php 490 2007-06-27 02:17:56Z roadydude $
//
// FILENAME  : cash_db.php
// STARTED   : Tue March 05, 2007
// COPYRIGHT : © 2006-2007 StarTrekGuide Development Group
// WWW       : http://startrekguide.com
// LICENCE   : All Rights Reserved
// 
// -------------------------------------------------------------

//
// Security message:
//
// This script is potentially dangerous.
// Do NOT FORGET to either remove this script or disable it after you have used it.
// Remove or uncomment the next line (die(".... ) to disable this script.
//
//die();
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

if (!$user->data['is_registered'])
{
    if ($user->data['is_bot'])
    {
        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
    }
    login_box('', 'LOGIN');
}
else if ($user->data['user_type'] != USER_FOUNDER)
{
	die('You are not allowed in here. :)');
}
$mode = request_var('mode', '');
$sql = $sql_id = array();

switch ($mode)
{
	case 'install':
		$sql[] = 'CREATE TABLE ' . $table_prefix . "cash_amt (
			user_id mediumint(8) unsigned NOT NULL default '0',
			cash_id mediumint(8) unsigned NOT NULL default '1',
			cash_amt int(15) unsigned NOT NULL default '0',
			KEY cash_user (user_id, cash_id)
			);";
		$sql[] = 'CREATE TABLE ' . $table_prefix . "cash (
				cash_id MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
				cash_name VARCHAR( 255 ) NOT NULL ,
				cash_value INT( 11 ) UNSIGNED NOT NULL DEFAULT '1',
				cash_trade TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1'
				)";
		$sql[] = 'INSERT INTO ' . $table_prefix . "cash (cash_id, cash_name, cash_value, cash_trade)
				VALUES ('1', 'Cash', '1', '1')";
	
		$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('f_cash', 0, 1);";
		$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('a_bank_manage', 1, 0);";
		$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('m_bank_manage', 1, 0);";
		
		$sql[] = 'ALTER TABLE ' . USERS_TABLE . " ADD user_cash int(11) unsigned NOT NULL default '0'";
		$sql[] = 'ALTER TABLE ' . USERS_TABLE . " ADD user_cash_date varchar(10) collate utf8_bin NOT NULL default ''";

		foreach ($sql as $var)
		{
			$db->sql_query($var);
			$sql_id[] = $db->sql_nextid();
		}
		unset($sql);
		set_config('cash_amt', 1);
		set_config('cash_id', 1);
		set_config('cash_mod', 1);
		set_config('cash_name', 'Cash');
		set_config('cash_limit', 0);
		set_config('cash_version', '0.3.1');
		set_config('load_tplcompile', 1);

		//setup cash to add up for all roles which allow posting without mod intervention
		$role_ary = "
		'ROLE_FORUM_LIMITED',
		'ROLE_FORUM_LIMITED_POLLS',
		'ROLE_FORUM_STANDARD',
		'ROLE_FORUM_POLLS',
		'ROLE_FORUM_FULL'";
		
		$sql = 'SELECT role_id
		FROM ' . ACL_ROLES_TABLE . "
		WHERE role_name IN ($role_ary)
		AND role_type = 'f_'";
		$result = $db->sql_query($sql);
		
		while ($row = $db->sql_fetchrow($result))
		{
			$sql_ary[] = array(
				'role_id'			=> $row['role_id'],
				'auth_option_id'	=> $sql_id[3],
				'auth_setting'		=> 1,
			);
		}
		$db->sql_freeresult($result);
		$db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);

		//insert the modules
		$sql = 'SELECT * FROM ' . MODULES_TABLE . " WHERE module_langname = 'ACP_CAT_DOT_MODS'";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		
		$sql_ary = array(
			'module_enabled'	=> 1,
			'module_display'	=> 1,
			'module_basename'	=> '',
			'module_class'		=> 'acp',
			'parent_id'			=> $row['module_id'],
			'left_id'			=> $row['right_id'],
			'right_id'			=> $row['right_id'] + 3,
			'module_langname'	=> 'ACP_HANDY_MODS',
			'module_mode'		=> '',
			'module_auth'		=> '',
		);
		
		$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
		$db->sql_query($sql);
		$module_id = $db->sql_nextid();
		
		$sql = 'UPDATE ' . MODULES_TABLE . "
		SET left_id = left_id + 4, right_id = right_id + 4
		WHERE left_id >= {$sql_ary['left_id']} AND module_id != $module_id";
		$db->sql_query($sql);
							
		$sql = 'UPDATE ' . MODULES_TABLE . "
		SET right_id = right_id + 4
		WHERE left_id < {$sql_ary['left_id']} AND right_id >= {$sql_ary['left_id']} AND module_id != $module_id";
		$db->sql_query($sql);
		
		$sql_ary = array(
			'module_enabled'	=> 1,
			'module_display'	=> 1,
			'module_basename'	=> 'cash',
			'module_class'		=> 'acp',
			'parent_id'			=> $module_id,
			'left_id'			=> $row['right_id'] + 1,
			'right_id'			=> $row['right_id'] + 2,
			'module_langname'	=> 'ACP_CASH',
			'module_mode'		=> 'default',
			'module_auth'		=> 'acl_a_',
		);
		
		$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
		$db->sql_query($sql);

		//install the bank management module into the UCP
		$sql = 'SELECT MAX(right_id) AS total_right FROM ' . MODULES_TABLE . " WHERE module_class = 'ucp'";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		
		$sql_ary = array(
			'module_enabled'	=> 1,
			'module_display'	=> 1,
			'module_basename'	=> '',
			'module_class'		=> 'ucp',
			'parent_id'			=> 0,
			'left_id'			=> $row['total_right'] + 1,
			'right_id'			=> $row['total_right'] + 4,
			'module_langname'	=> 'UCP_BANK',
			'module_mode'		=> '',
			'module_auth'		=> '',
		);
		
		$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
		$db->sql_query($sql);
		$module_id = $db->sql_nextid();
		
		$sql_ary = array(
			'module_enabled'	=> 1,
			'module_display'	=> 1,
			'module_basename'	=> 'bank',
			'module_class'		=> 'ucp',
			'parent_id'			=> $module_id,
			'left_id'			=> $row['total_right'] + 2,
			'right_id'			=> $row['total_right'] + 3,
			'module_langname'	=> 'UCP_BANK_MANAGEMENT',
			'module_mode'		=> 'management',
			'module_auth'		=> 'acl_a_bank_manage || acl_m_bank_manage',
		);
		
		$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
		$db->sql_query($sql);
		
		//all is finished… remove this file and purge the cache
		global $cache;
		$cache->purge();
		add_log('admin', 'LOG_PURGE_CACHE');
		if (file_exists('cash_db.php'))
		{
			$unlink = @unlink('cash_db.php') ? '' : 'Delete this file (cash_db.php) from your server.';
		}
		trigger_error("Database successfully updated. This mod has been installed into the ACP/.MODS<br />
		$unlink When you are finished installing the cash mod, make sure to purge the cache using the purge cache option in the ACP");
	break;
}
?>
 
Subzonline said:
it has the 0.3.2 cash mod installed on the database, i have removed the cash mod tables and removed the queries in the config table but its no use as the cash mod still appears in the mod tb in ACP.
Even if there are some tables left for the cash mod it wouldn't keep it showing in the acp. It is the module that is still there so if you remove it in the same way you add a new module in the acp it will go. If there is any mod data in the db it won't cause it to keep showing and it shouldn't interfere with new mods showing. When you ran the sql for the points mod did it run successfully or did you get an error saying that a certain table existed? If it ran successfully then the cash mod is in no way affecting the point mod.

About the points mod not showing up it doesn't have it's own module like the old one. The points settings are added onto the post settings section so that might be why you can't find them -😉-
 
The best way to clean out a database is by taking a backup and removing the unneeded values, and dropping the unused tables in phpMyAdmin. Like fowler said, the only reason a module is still showing is because you haven't deleted it from the ACP. The cash mod tables and config values won't affect the installation of the simple points mod as they use their own table(s) with a different name and the config table values are named different as well.
 
Back
Top Bottom