Page 32 of 74

Re: [ALPHA] Shop Mod (0.3.0)

Posted: Wed Jun 18, 2008 11:07 am
by ginny2689
pls somebody tell me who do i add items? :roll:
ginny2689 wrote:i don't know much
can u explain me in detail how do i add items & where?
Gleasonator wrote:
ginny2689 wrote:pls help me

whenever i click on Shop the following informaion came

Forum Shop

Sorry, the shop is closed at this time.

how can i open the shop pls tell me

Thanks!!
Add an item to the shop and it will open automatically.

Re: [ALPHA] Shop Mod (0.3.0)

Posted: Wed Jun 18, 2008 11:16 am
by hmingtea
i'm using a ProSilver Based templates (StarCraft) ... can i get an installation guide for this Mod... ive done everything except this template part...

Re: [ALPHA] Shop Mod (0.3.0)

Posted: Wed Jun 18, 2008 3:22 pm
by Gleasonator
hmingtea wrote:i'm using a ProSilver Based templates (StarCraft) ... can i get an installation guide for this Mod... ive done everything except this template part...
First of all, make sure the shop template files from the mod are uploaded into that folder. What I mean is, in the "root/styles" folder that came with your mod, put all the contents of the "prosilver" folder into the starcraft folder on your webserver.

Once that is done, the template edits are only optional, not required. You can try to follow the step-by-step guide prosilver guide bu instead of editing prosilver, edit StarCraft. But if it doesn't work for your style (and sometimes it wont) you can always just make a thread and point your users to yoursite.com/forums/site.php

Re: [ALPHA] Shop Mod (0.3.0)

Posted: Wed Jun 18, 2008 8:51 pm
by Phantom784
Gleasonator wrote:Sorry about my last post. That was an issue with the cash mod that I resolved.

I have a bug to submit, though. I've found that, using a simple URL query, anyone can obtain cash points by selling items that they don't have to the shop, and they can also drain the quantity of items.

If you submit the query: http://yoursite.com/forums/shop.php?mode=buy&item=item_id

Then choose that you would like to purchase the item, it will tell you that you cannot and wont let you, but the stock of the item still decreases by 1.

What's worse, though, is that with this query: http://yoursite.com/forums/ucp.php?i=shop&mode=inventory&action=sellback&item=item_id

A user can "sell" back an item that he or she doesn't have. It will increase the stock of that item in the shop by 1 point, and will give the user who submitted that query as much cash as the item is worth. This is especially bad when the item has a very large sellback price. Any user could take over the whole shop by using this method.

EDIT: I think the best way to resolve this is to a make seperate PHP file for the shop, and one for actually purchasing the item.
I tested both of these cases on my development server, and the bug isn't there, so the next release should fix this problem.

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Thu Jun 19, 2008 9:35 pm
by Phantom784
I just released the next verison. Get it at http://radoncube.com/mods/shop_mod_0.4.0.zip

Please note that I have not spent much time testing this, so I would HIGHLY advise you not to use it on a live forum, at least not without heavily testing it on a private server (which I am going to do myself). I just wanted to release it earlier to hopefully get more people to look at in and catch more bugs.

Among other things, this mod includes the much-awaited shelf feature and an installer, so that people don't have to worry about adding modules and manually running SQL queries. The installer should also perform upgrades. If it says that it auto-detected something different than what you have (eg it says it's going to do a fresh install but you're upgrading), don't run it an let me know so I can work out the bug.

Other than that, enjoy the MOD!

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 12:50 am
by ihermit
Yes! I'm sooo happy!
I've been waiting for so long!

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 1:47 am
by ihermit
Alright, everything went well except for one thing. When I ran the database install it gives me:
The file ./styles//template/bbcode.html is missing.
But it's not:)

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 1:51 am
by Gleasonator
Phantom784 wrote:I just released the next verison. Get it at http://radoncube.com/mods/shop_mod_0.4.0.zip

Please note that I have not spent much time testing this, so I would HIGHLY advise you not to use it on a live forum, at least not without heavily testing it on a private server (which I am going to do myself). I just wanted to release it earlier to hopefully get more people to look at in and catch more bugs.

Among other things, this mod includes the much-awaited shelf feature and an installer, so that people don't have to worry about adding modules and manually running SQL queries. The installer should also perform upgrades. If it says that it auto-detected something different than what you have (eg it says it's going to do a fresh install but you're upgrading), don't run it an let me know so I can work out the bug.

Other than that, enjoy the MOD!
Yeah! :D Thanks for the update!

A problem though... when running the installer to upgrade from 0.3.0 to now, I get this error:

Code: Select all

Shop Mod Installer
template->_tpl_load_file(): File /confirm_body.html does not exist or is empty
I've tried with two different skins (one of which being prosilver), both of which contain the file "confirm_body.html". I've also tried refreshing my cache, and I'm positive that the file is there and clean... the installer just wont seem to pick it up.

I uploaded all files as instructed. The install file is on the root of my forums, in the same folder as config.php and common.php.

Any help? Your work on this mod is greatly appreciated. And I'm very excited about the new update. :)

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 1:56 am
by Topdrag
I had the same issue.

Here is the error output that I got from the installer. (Going from 0.3.0 to 0.4.0)

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/session.php on line 1810: strtr() [function.strtr]: The second argument is not an array
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1810: strtr() [function.strtr]: The second argument is not an array
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1810: strtr() [function.strtr]: The second argument is not an array
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1810: strtr() [function.strtr]: The second argument is not an array
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 13807: Cannot modify header information - headers already sent by (output started at /includes/functions.php:11638)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 13815: Cannot modify header information - headers already sent by (output started at /includes/functions.php:11638)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 13819: Cannot modify header information - headers already sent by (output started at /includes/functions.php:11638)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 13823: Cannot modify header information - headers already sent by (output started at /includes/functions.php:11638)
Shop Mod Installer
template->_tpl_load_file(): File /confirm_body.html does not exist or is empty

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:10 am
by ihermit
Gleasonator wrote:
Phantom784 wrote:I just released the next verison. Get it at http://radoncube.com/mods/shop_mod_0.4.0.zip

Please note that I have not spent much time testing this, so I would HIGHLY advise you not to use it on a live forum, at least not without heavily testing it on a private server (which I am going to do myself). I just wanted to release it earlier to hopefully get more people to look at in and catch more bugs.

Among other things, this mod includes the much-awaited shelf feature and an installer, so that people don't have to worry about adding modules and manually running SQL queries. The installer should also perform upgrades. If it says that it auto-detected something different than what you have (eg it says it's going to do a fresh install but you're upgrading), don't run it an let me know so I can work out the bug.

Other than that, enjoy the MOD!
Yeah! :D Thanks for the update!

A problem though... when running the installer to upgrade from 0.3.0 to now, I get this error:

Code: Select all

Shop Mod Installer
template->_tpl_load_file(): File /confirm_body.html does not exist or is empty
I've tried with two different skins (one of which being prosilver), both of which contain the file "confirm_body.html". I've also tried refreshing my cache, and I'm positive that the file is there and clean... the installer just wont seem to pick it up.

I uploaded all files as instructed. The install file is on the root of my forums, in the same folder as config.php and common.php.

Any help? Your work on this mod is greatly appreciated. And I'm very excited about the new update. :)
Same, also I'm doing a fresh install of 0.4.0, and I can't get the acp modules to show up. I created a new catagory in .mods, named it shop. I then added the two shop modules, and enabled them. They're not showing up.

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:13 am
by Gleasonator
ihermit wrote:Same, also I'm doing a fresh install of 0.4.0, and I can't get the acp modules to show up. I created a new catagory in .mods, named it shop. I then added the two shop modules, and enabled them. They're not showing up.
I overwrote my 0.3.0 files with the 0.4.0 ones and I'm noticing the new stuff in the ACP modules (such as configuration settings). However, the configuration settings wont submit with the 0.3.0 database stuff... so I'm stuck with the shop closed (as it's closed by default in 0.4.0) until the database is updated. :lol:

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:18 am
by ihermit
Gleasonator wrote:
ihermit wrote:Same, also I'm doing a fresh install of 0.4.0, and I can't get the acp modules to show up. I created a new catagory in .mods, named it shop. I then added the two shop modules, and enabled them. They're not showing up.
I overwrote my 0.3.0 files with the 0.4.0 ones and I'm noticing the new stuff in the ACP modules (such as configuration settings). However, the configuration settings wont submit with the 0.3.0 database stuff... so I'm stuck with the shop closed (as it's closed by default in 0.4.0) until the database is updated. :lol:
I downloaded the 3.0, and ran the queries. I still can't see the modules, will I need to wait for the 4.0 database update to see them? Because I have no idea why they're not showing up:(

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:19 am
by Phantom784
Try the following version of shop_mod_install.php. It seams to work for me. If others report success with it, I'll re-release the new installer as 0.4.0a

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/shop');
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)
{
	trigger_error('NOT_AUTHORISED');
}

//okay, we're safe to install
$msg_title = 'Shop Mod Installer';
if (!file_exists($phpbb_root_path . 'includes/functions_shop.' . $phpEx))
{
	trigger_error('You have to complete the installation instructions in install.xml before running this installer!');
}
include($phpbb_root_path . 'includes/functions_shop.' . $phpEx);
$shop = new shop;
if (!defined('SHOP_VERSION'))
{
	//they're running a legacy (pre-installer) version
	trigger_error('You have to complete the upgrade instructions before running this installer!');
}
if (SHOP_VERSION != '0.4.0')
{
	if (version_compare(SHOP_VERSION, '0.4.0') == -1)
	{
		trigger_error('You have to complete the upgrade instructions before running this installer!');
	}
	else
	{
		trigger_error('This installer is for an older version. Use the installer for version ' . SHOP_VERSION);
	}
}

//now we have to figure out what version is currently installed in the database to know if/how to upgrade

if(!$config['shop_mod_version'])
{
	//either a fresh install or legacy version
	$db->sql_return_on_error(false);
	if (!$db->sql_query('SELECT * FROM ' . SHOP_ITEMS_TABLE))
	{
		$old_version = 0;	
	}
	else
	{
		//uh oh, legacy version, we'll need some tricks to see which one
		if (!$db->sql_query('SELECT * FROM ' . SHOP_ITEMS_USER_TABLE))
		{
			$old_version = '0.1.0';	
		}
		elseif(!$db->sql_query('SELECT can_trash FROM ' . SHOP_ITEMS_TABLE))
		{
			$old_version = '0.2.0';
		}
		else
		{
			$old_version = '0.3.0';
		}
	}
	$db->sql_return_on_error(false);
}
else
{
	$old_version = $config['shop_mod_version'];
}
if ($old_version == SHOP_VERSION)
{
	trigger_error('Version ' . SHOP_VERSION . ' already installed.');
}

//now we figure out the cash system in use
if($config['cash_mod'] and $config['points_enable'])
{
	//if both systems are detected, give the user the choice as to which to use
	switch (request_var('money','none'))
	{
		case 'cashmod':
			$cash = 'cashmod';
		break;
		case 'simplepoints':
			$cash = 'simplepoints';
		break;
		default:
			trigger_error('<form method="GET" action="' . append_sid("{$phpbb_root_path}shop_mod_install.$phpEx") . '">Both Cash Mod and Simple Points have been detected!
			Please select which system the shop mod should work with. <select name="money" id="money"><option value="cashmod">Cash Mod</option><option value="simplepoints">Simple Points</option></select>
			<input type="submit" value="Choose" /></form>');
		break;
	}
}
elseif($config['cash_mod'])
{
	$cash = 'cashmod';
}
elseif($config['points_enable'])
{
	$cash = 'simplepoints';
}
else
{
	//If you are using a custom money system besides the two that are supported, comment out the following line in order to proceed with the installation.
	trigger_error('Neither Cash Mod nor Simple Points has been detected.  One of these must be installed in order to install the shop mod.');
}

if (confirm_box(true))
{
	$db->sql_transaction('begin');
	//here, we actually do the install or upgrade
	$sql = array();
	if (!$old_version or version_compare($old_version, '0.3.0', 'le'))
	{
		//setup config options
		set_config('shop_open', 0);
		set_config('shoplink_show', 1);
		set_config('shop_pm_on_buy', 0);
		set_config('shop_shelf_size_sig', 0);
		set_config('shop_mod_version', '0.4.0');
		set_config('shop_money_system', $cash);

		//and acl permissions
		permission_setup();
		if ($old_version)
		{
			module_seek_and_destroy();
		}
		module_setup();

		switch ($old_version)
		{
			case 0:
				$sql[] = 'CREATE TABLE `' . SHOP_ITEMS_TABLE . '` (
				`item` mediumint(8) unsigned NOT NULL auto_increment,
				`name` varchar(100) collate utf8_bin NOT NULL,
				`description` varchar(255) collate utf8_bin NOT NULL,
				`backend` varchar(255) collate utf8_bin NOT NULL,
				`icon` varchar(100) collate utf8_bin NOT NULL,
				`icon_width` tinyint(4) NOT NULL default \'0\',
				`icon_height` tinyint(4) NOT NULL default \'0\'
				`quantity` mediumint(8) unsigned NOT NULL default \'0\',
				`price` mediumint(8) unsigned NOT NULL default \'0\',
				`sell_price` mediumint(8) unsigned NOT NULL default \'0\',
				`item_order` mediumint(8) unsigned NOT NULL default \'0\',
				`instant_use` tinyint(1) NOT NULL default \'0\',
				`can_sellback` tinyint(1) NOT NULL default \'0\',
				`can_trash` tinyint(1) NOT NULL default \'0\',
				`can_display` tinyint(1) NOT NULL default \'0\',
				PRIMARY KEY  (`item`)
				) CHARSET=utf8 COLLATE=utf8_bin';

				$sql[] = 'CREATE TABLE `' . SHOP_ITEMS_USER_TABLE . '` (
				`item_user` mediumint(8) unsigned NOT NULL auto_increment,
				`item` mediumint(8) unsigned NOT NULL,
				`user` mediumint(8) unsigned NOT NULL,
				`quantity_user` mediumint(8) unsigned default NULL,
				`shelf_display` tinyint(1) NOT NULL default \'0\',
				PRIMARY KEY  (`item_user`)
				) CHARSET=utf8 COLLATE=utf8_bin';
			break;
			case '0.1.0':
				$sql[] = 'CREATE TABLE ' . SHOP_ITEMS_USER_TABLE . ' ( item_user mediumint(8) unsigned NOT NULL auto_increment, item mediumint(8) unsigned NOT NULL, `user` mediumint(8) unsigned NOT NULL,
						quantity_user mediumint(8) unsigned default NULL, PRIMARY KEY  (item_user)) CHARSET=utf8 COLLATE=utf8_bin';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `price` mediumint(8) unsigned NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `item_order` mediumint(8) unsigned NOT NULL default \'0\'';
			//no break
			case '0.2.0':
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `backend` varchar(255) collate utf8_bin NOT NULL';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `sell_price` mediumint(8) unsigned NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `instant_use` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_sellback` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_trash` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'UPDATE ' . SHOP_ITEMS_TABLE . ' SET `backend`=\'blank\'';
			//no break
			case '0.3.0':
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `icon_width` tinyint(4) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `icon_height` tinyint(4) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_display` tinyint(1) NOT NULL default \'0\'';
			break;
			default:
				trigger_error('You shouldn\'t be seeing this.  It means something is wrong with the installer. Let me know at phantom AT radoncube.com or post on the mod\'s topic on phpbb.com.');
			break;
		}
		foreach ($sql as $var)
		{
			$db->sql_query($var);
		}
		set_icon_dimensions();
		if ($oldversion == '0.1.0')
		{
			resync_item_order();
		}
	}
	//at this point, we're up to 0.4.0
	//when we make new versions, we'll do the update here
	$db->sql_transaction('confirm');

	//clear cache
	$cache->destroy('_modules_acp');
	$cache->destroy('_modules_ucp');
	$cache->destroy('sql', MODULES_TABLE);
	require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); //for filelist()
	$cachelist = filelist($phpbb_root_path . $img_path, '');
	$dh = @opendir($phpbb_root_path . 'cache');
	while (($fname = readdir($dh)) !== false)
	{
		if (is_file($phpbb_root_path . 'cache/' . $fname) and strpos($fname, 'prosilver'))
		{
			@unlink($phpbb_root_path . 'cache/' . $fname);
		}
	}
	trigger_error('Install Complete!');
}
else
{
	$s_hidden_fields = build_hidden_fields(array(
		'submit'	=> true,
		)
	);
	$message = '';
	//display mode
	$message = 'The installer has detected that it needs to perform ';
	if ($oldversion == 0)
	{
		$message .= 'a fresh install';
	}
	else
	{
		$message .= 'an upgrade from version ' . $oldversion;
	}
	if ($cash == 'cashmod')
	{
		$message .= ', using the Cash Mod as its money system';
	}
	elseif ($cash == 'simplepoints')
	{
		$message .= ', using the Simple Points System as its money system';
	}
	$message .= '. Is this correct?';
	confirm_box(false, $message, $s_hidden_fields);
	redirect(append_sid("{$phpbb_root_path}shop_mod_install.$phpEx"));
}

function resync_item_order()
{
	global $db;
	// this fun snippet of code stolen from acp_icons.php
	$sql = 'SELECT item, item_order FROM ' . SHOP_ITEMS_TABLE . ' ORDER BY item_order';
	$result = $db->sql_query($sql);

	if ($row = $db->sql_fetchrow($result))
	{
		$order = 0;
		do
		{
			++$order;
			if ($row['item_order'] != $order)
			{
				$db->sql_query('UPDATE ' . SHOP_ITEMS_TABLE . " SET item_order = $order WHERE item = " . $row['item']);
			}
		}
		while ($row = $db->sql_fetchrow($result));
	}
	$db->sql_freeresult($result);
}

function set_icon_dimensions()
{
	global $db, $phpbb_root_path;
	$img_path = 'images/icons/shop_icons/';
	$sql = 'SELECT * FROM ' . SHOP_ITEMS_TABLE;
	$result = $db->sql_query($sql);
	while($row = $db->sql_fetchrow($result))
	{
		if ($row['icon'] != '0')
		{
			$img_size = getimagesize($phpbb_root_path . $img_path . '/' . $row['icon']);
			$icon_width = $img_size[0];
			$icon_height = $img_size[1];
		}
		else
		{
			$icon_width = 0;
			$icon_height = 0;
		}
		$sql = 'UPDATE ' .  SHOP_ITEMS_TABLE . " SET icon_width = $icon_width, icon_height = $icon_height WHERE item = {$row['item']}";
		$db->sql_query($sql);
	}
}

function module_setup()
{
	global $db;

	//ACP 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'] + 5,
		'module_langname'	=> 'ACP_PHANTOMS_MODS',
		'module_mode'		=> '',
		'module_auth'		=> '',
	);
	$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id + 6 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id >= ' . $row['right_id'];
	$db->sql_query($sql);
	$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id + 6 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
	$db->sql_query($sql);
	$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'	=> 'shop_mod',
		'module_class'		=> 'acp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['right_id'] + 1,
		'right_id'			=> $row['right_id'] + 2,
		'module_langname'	=> 'ACP_SHOP_CONFIG',
		'module_mode'		=> 'config',
		'module_auth'		=> 'acl_a_shop_mod',
	);	
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);

	$sql_ary = array(
		'module_enabled'	=> 1,
		'module_display'	=> 1,
		'module_basename'	=> 'shop_mod',
		'module_class'		=> 'acp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['right_id'] + 3,
		'right_id'			=> $row['right_id'] + 4,
		'module_langname'	=> 'ACP_SHOP_ITEMS',
		'module_mode'		=> 'items',
		'module_auth'		=> 'acl_a_shop_mod',
	);	
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);

	//UCP modules
	$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);
	$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_SHOP',
		'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'	=> 'shop',
		'module_class'		=> 'ucp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['total_right'] + 2,
		'right_id'			=> $row['total_right'] + 3,
		'module_langname'	=> 'UCP_SHOP_INVENTORY',
		'module_mode'		=> 'inventory',
		'module_auth'		=> '',
	);
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

function permission_setup()
{
	global $db;

	//this permission lets admins access the shop mod acp panel
	$sql = 'INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES (\'a_shop_mod\', 1, 0, 0)';
	$result = $db->sql_query($sql);
	$id = $db->sql_nextid();

	//give this permission to anyone with the acl_a_board permission
	$sql = 'SELECT auth_option_id FROM phpbb_acl_options WHERE auth_option = \'a_board\'';
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$auth_id = $row['auth_option_id'];

	$tables = array('phpbb_acl_groups', 'phpbb_acl_users', 'phpbb_acl_roles_data');
	foreach ($tables as $table)
	{
		$sql = 'SELECT * FROM ' . $table . " WHERE auth_option_id = '$auth_id'";
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			$row['auth_option_id'] = $id;
			$sql = 'INSERT INTO ' . $table . $db->sql_build_array('INSERT', $row);
			$db->sql_query($sql);
		}
	}
	//destroy user permission cache
	$sql = 'UPDATE ' . USERS_TABLE . ' SET user_permissions = \'\', user_perm_from = 0';
	$db->sql_query($sql);
}

function module_seek_and_destroy()
{
	global $db, $cache;
	$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_basename = \'shop\' or module_basename = \'shop_mod\'';
	$result = $db->sql_query($sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
		$result_2 = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result_2);
		$sql = 'DELETE FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
		$db->sql_query($sql);
		//check to see if the module left any orphans (there's no reason why it should, the acp only lets categories have children)
		if ($row['left_id'] + 1 != $row['right_id'])
		{
			//let the grandparent adopt the oprhans since we killed the parent (isn't that a nice image)
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id -1, right_id = right_id - 1, parent_id = ' . $row['parent_id'] . ' WHERE module_class = \'' . $row['module_class'] . '\' AND left_id BETWEEN ' . $row['left_id'] . ' AND ' . $row['right_id'];
			$db->sql_query($sql);
		}
		$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id > ' . $row['right_id'];
		$db->sql_query($sql);
		$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
		$db->sql_query($sql);
		//if an empty parent class is left behind, get rid of it too
		while ($parent_id = $row['parent_id'])
		{
			$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $parent_id;
			$result_2 = $db->sql_query($sql);
			$row = $db->sql_fetchrow($result_2);
			if ($row['left_id'] + 1 != $row['right_id'] or $row['module_langname'] == 'ACP_CAT_DOT_MODS')
			{
				break;
			}
			$sql = 'DELETE FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
			$db->sql_query($sql);
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id > ' . $row['right_id'];
			$db->sql_query($sql);
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
			$db->sql_query($sql);
		}
	}
}

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:21 am
by ihermit
Phantom784 wrote:Try the following version of shop_mod_install.php. It seams to work for me. If others report success with it, I'll re-release the new installer as 0.4.0a

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/shop');

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)
{
	trigger_error('NOT_AUTHORISED');
}

//okay, we're safe to install
$msg_title = 'Shop Mod Installer';
if (!file_exists($phpbb_root_path . 'includes/functions_shop.' . $phpEx))
{
	trigger_error('You have to complete the installation instructions in install.xml before running this installer!');
}
include($phpbb_root_path . 'includes/functions_shop.' . $phpEx);
$shop = new shop;
if (!defined('SHOP_VERSION'))
{
	//they're running a legacy (pre-installer) version
	trigger_error('You have to complete the upgrade instructions before running this installer!');
}
if (SHOP_VERSION != '0.4.0')
{
	if (version_compare(SHOP_VERSION, '0.4.0') == -1)
	{
		trigger_error('You have to complete the upgrade instructions before running this installer!');
	}
	else
	{
		trigger_error('This installer is for an older version. Use the installer for version ' . SHOP_VERSION);
	}
}

//now we have to figure out what version is currently installed in the database to know if/how to upgrade
if(!$config['shop_mod_version'])
{
	//either a fresh install or legacy version
	$db->sql_return_on_error(true);
	if (!$db->sql_query('SELECT * FROM ' . SHOP_ITEMS_TABLE))
	{
		$old_version = 0;	
	}
	else
	{
		//uh oh, legacy version, we'll need some tricks to see which one
		if (!$db->sql_query('SELECT * FROM ' . SHOP_ITEMS_USER_TABLE))
		{
			$old_version = '0.1.0';	
		}
		elseif(!$db->sql_query('SELECT can_trash FROM ' . SHOP_ITEMS_TABLE))
		{
			$old_version = '0.2.0';
		}
		else
		{
			$old_version = '0.3.0';
		}
	}
	$db->sql_return_on_error(false);
}
else
{
	$old_version = $config['shop_mod_version'];
}
if ($old_version == SHOP_VERSION)
{
	//trigger_error('Version ' . SHOP_VERSION . ' already installed.');
}

//now we figure out the cash system in use
if($config['cash_mod'] and $config['points_enable'])
{
	//if both systems are detected, give the user the choice as to which to use
	switch (request_var('money','none'))
	{
		case 'cashmod':
			$cash = 'cashmod';
		break;
		case 'simplepoints':
			$cash = 'simplepoints';
		break;
		default:
			trigger_error('<form method="GET" action="' . append_sid("{$phpbb_root_path}shop_mod_install.$phpEx") . '">Both Cash Mod and Simple Points have been detected!
			Please select which system the shop mod should work with. <select name="money" id="money"><option value="cashmod">Cash Mod</option><option value="simplepoints">Simple Points</option></select>
			<input type="submit" value="Choose" /></form>');
		break;
	}
}
elseif($config['cash_mod'])
{
	$cash = 'cashmod';
}
elseif($config['points_enable'])
{
	$cash = 'simplepoints';
}
else
{
	//If you are using a custom money system besides the two that are supported, comment out the following line in order to proceed with the installation.
	trigger_error('Neither Cash Mod nor Simple Points has been detected.  One of these must be installed in order to install the shop mod.');
}

if (confirm_box(true))
{
	$db->sql_transaction('begin');
	//here, we actually do the install or upgrade
	$sql = array();
	if (!$old_version or version_compare($old_version, '0.3.0', 'le'))
	{
		//setup config options
		set_config('shop_open', 0);
		set_config('shoplink_show', 1);
		set_config('shop_pm_on_buy', 0);
		set_config('shop_shelf_size_sig', 0);
		set_config('shop_mod_version', '0.4.0');
		set_config('shop_money_system', $cash);

		//and acl permissions
		permission_setup();
		if ($old_version)
		{
			module_seek_and_destroy();
		}
		module_setup();

		switch ($old_version)
		{
			case 0:
				$sql[] = 'CREATE TABLE `' . SHOP_ITEMS_TABLE . '` (
				`item` mediumint(8) unsigned NOT NULL auto_increment,
				`name` varchar(100) collate utf8_bin NOT NULL,
				`description` varchar(255) collate utf8_bin NOT NULL,
				`backend` varchar(255) collate utf8_bin NOT NULL,
				`icon` varchar(100) collate utf8_bin NOT NULL,
				`icon_width` tinyint(4) NOT NULL default \'0\',
				`icon_height` tinyint(4) NOT NULL default \'0\'
				`quantity` mediumint(8) unsigned NOT NULL default \'0\',
				`price` mediumint(8) unsigned NOT NULL default \'0\',
				`sell_price` mediumint(8) unsigned NOT NULL default \'0\',
				`item_order` mediumint(8) unsigned NOT NULL default \'0\',
				`instant_use` tinyint(1) NOT NULL default \'0\',
				`can_sellback` tinyint(1) NOT NULL default \'0\',
				`can_trash` tinyint(1) NOT NULL default \'0\',
				`can_display` tinyint(1) NOT NULL default \'0\',
				PRIMARY KEY  (`item`)
				) CHARSET=utf8 COLLATE=utf8_bin';

				$sql[] = 'CREATE TABLE `' . SHOP_ITEMS_USER_TABLE . '` (
				`item_user` mediumint(8) unsigned NOT NULL auto_increment,
				`item` mediumint(8) unsigned NOT NULL,
				`user` mediumint(8) unsigned NOT NULL,
				`quantity_user` mediumint(8) unsigned default NULL,
				`shelf_display` tinyint(1) NOT NULL default \'0\',
				PRIMARY KEY  (`item_user`)
				) CHARSET=utf8 COLLATE=utf8_bin';
			break;
			case '0.1.0':
				$sql[] = 'CREATE TABLE ' . SHOP_ITEMS_USER_TABLE . ' ( item_user mediumint(8) unsigned NOT NULL auto_increment, item mediumint(8) unsigned NOT NULL, `user` mediumint(8) unsigned NOT NULL,
						quantity_user mediumint(8) unsigned default NULL, PRIMARY KEY  (item_user)) CHARSET=utf8 COLLATE=utf8_bin';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `price` mediumint(8) unsigned NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `item_order` mediumint(8) unsigned NOT NULL default \'0\'';
			//no break
			case '0.2.0':
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `backend` varchar(255) collate utf8_bin NOT NULL';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `sell_price` mediumint(8) unsigned NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `instant_use` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_sellback` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_trash` tinyint(1) NOT NULL default \'0\'';
				$sql[] = 'UPDATE ' . SHOP_ITEMS_TABLE . ' SET `backend`=\'blank\'';
			//no break
			case '0.3.0':
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `icon_width` tinyint(4) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `icon_height` tinyint(4) NOT NULL default \'0\'';
				$sql[] = 'ALTER TABLE ' . SHOP_ITEMS_TABLE . ' ADD `can_display` tinyint(1) NOT NULL default \'0\'';
			//no break
			default:
				trigger_error('You shouldn\'t be seeing this.  It means something is wrong with the installer. Let me know at phantom AT radoncube.com or post on the mod\'s topic on phpbb.com.');
			break;
		}
		foreach ($sql as $var)
		{
			$db->sql_query($var);
		}
		set_icon_dimensions();
		if ($oldversion == '0.1.0')
		{
			resync_item_order();
		}
	}
	//at this point, we're up to 0.4.0
	//when we make new versions, we'll do the update here
	$db->sql_transaction('confirm');

	//clear cache
	$cache->destroy('_modules_acp');
	$cache->destroy('_modules_ucp');
	$cache->destroy('sql', MODULES_TABLE);
	$cachelist = filelist($phpbb_root_path . $img_path, '');
	require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); //for filelist()
	$dh = @opendir($phpbb_root_path . 'cache');
	while (($fname = readdir($dh)) !== false)
	{
		if (is_file($phpbb_root_path . 'cache/' . $fname) and strpos($fname, 'prosilver'))
		{
			@unlink($phpbb_root_path . 'cache/' . $fname);
		}
	}
}
else
{
	$s_hidden_fields = build_hidden_fields(array(
		'submit'	=> true,
		)
	);
	$message = '';
	//display mode
	$message = 'The installer has detected that it needs to perform ';
	if ($oldversion == 0)
	{
		$message .= 'a fresh install';
	}
	else
	{
		$message .= 'an upgrade from version ' . $oldversion;
	}
	if ($cash == 'cashmod')
	{
		$message .= ', using the Cash Mod as its money system';
	}
	elseif ($cash == 'simplepoints')
	{
		$message .= ', using the Simple Points System as its money system';
	}
	$message .= '. Is this correct?';
	confirm_box(false, $message, $s_hidden_fields);
	redirect(append_sid("{$phpbb_root_path}shop_mod_install.$phpEx"));
}

function resync_item_order()
{
	global $db;
	// this fun snippet of code stolen from acp_icons.php
	$sql = 'SELECT item, item_order FROM ' . SHOP_ITEMS_TABLE . ' ORDER BY item_order';
	$result = $db->sql_query($sql);

	if ($row = $db->sql_fetchrow($result))
	{
		$order = 0;
		do
		{
			++$order;
			if ($row['item_order'] != $order)
			{
				$db->sql_query('UPDATE ' . SHOP_ITEMS_TABLE . " SET item_order = $order WHERE item = " . $row['item']);
			}
		}
		while ($row = $db->sql_fetchrow($result));
	}
	$db->sql_freeresult($result);
}

function set_icon_dimensions()
{
	global $db, $phpbb_root_path;
	$img_path = 'images/icons/shop_icons/';
	$sql = 'SELECT * FROM ' . SHOP_ITEMS_TABLE;
	$result = $db->sql_query($sql);
	while($row = $db->sql_fetchrow($result))
	{
		if ($row['icon'] != '0')
		{
			$img_size = getimagesize($phpbb_root_path . $img_path . '/' . $row['icon']);
			$icon_width = $img_size[0];
			$icon_height = $img_size[1];
		}
		else
		{
			$icon_width = 0;
			$icon_height = 0;
		}
		$sql = 'UPDATE ' .  SHOP_ITEMS_TABLE . " SET icon_width = $icon_width, icon_height = $icon_height WHERE item = {$row['item']}";
		$db->sql_query($sql);
	}
}

function module_setup()
{
	global $db;

	//ACP 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'] + 5,
		'module_langname'	=> 'ACP_PHANTOMS_MODS',
		'module_mode'		=> '',
		'module_auth'		=> '',
	);
	$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id + 6 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id >= ' . $row['right_id'];
	$db->sql_query($sql);
	$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id + 6 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
	$db->sql_query($sql);
	$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'	=> 'shop_mod',
		'module_class'		=> 'acp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['right_id'] + 1,
		'right_id'			=> $row['right_id'] + 2,
		'module_langname'	=> 'ACP_SHOP_CONFIG',
		'module_mode'		=> 'config',
		'module_auth'		=> 'acl_a_shop_mod',
	);	
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);

	$sql_ary = array(
		'module_enabled'	=> 1,
		'module_display'	=> 1,
		'module_basename'	=> 'shop_mod',
		'module_class'		=> 'acp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['right_id'] + 3,
		'right_id'			=> $row['right_id'] + 4,
		'module_langname'	=> 'ACP_SHOP_ITEMS',
		'module_mode'		=> 'items',
		'module_auth'		=> 'acl_a_shop_mod',
	);	
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);

	//UCP modules
	$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);
	$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_SHOP',
		'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'	=> 'shop',
		'module_class'		=> 'ucp',
		'parent_id'			=> $module_id,
		'left_id'			=> $row['total_right'] + 2,
		'right_id'			=> $row['total_right'] + 3,
		'module_langname'	=> 'UCP_SHOP_INVENTORY',
		'module_mode'		=> 'inventory',
		'module_auth'		=> '',
	);
	$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

function permission_setup()
{
	global $db;

	//this permission lets admins access the shop mod acp panel
	$sql = 'INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES (\'a_shop_mod\', 1, 0, 0)';
	$result = $db->sql_query($sql);
	$id = $db->sql_nextid();

	//give this permission to anyone with the acl_a_board permission
	$sql = 'SELECT auth_option_id FROM phpbb_acl_options WHERE auth_option = \'a_board\'';
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$auth_id = $row['auth_option_id'];

	$tables = array('phpbb_acl_groups', 'phpbb_acl_users', 'phpbb_acl_roles_data');
	foreach ($tables as $table)
	{
		$sql = 'SELECT * FROM ' . $table . " WHERE auth_option_id = '$auth_id'";
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			$row['auth_option_id'] = $id;
			$sql = 'INSERT INTO ' . $table . $db->sql_build_array('INSERT', $row);
			$db->sql_query($sql);
		}
	}
	//destroy user permission cache
	$sql = 'UPDATE ' . USERS_TABLE . ' SET user_permissions = \'\', user_perm_from = 0';
	$db->sql_query($sql);
}

function module_seek_and_destroy()
{
	global $db, $cache;
	$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_basename = \'shop\' or module_basename = \'shop_mod\'';
	$result = $db->sql_query($sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
		$result_2 = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result_2);
		$sql = 'DELETE FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
		$db->sql_query($sql);
		//check to see if the module left any orphans (there's no reason why it should, the acp only lets categories have children)
		if ($row['left_id'] + 1 != $row['right_id'])
		{
			//let the grandparent adopt the oprhans since we killed the parent (isn't that a nice image)
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id -1, right_id = right_id - 1, parent_id = ' . $row['parent_id'] . ' WHERE module_class = \'' . $row['module_class'] . '\' AND left_id BETWEEN ' . $row['left_id'] . ' AND ' . $row['right_id'];
			$db->sql_query($sql);
		}
		$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id > ' . $row['right_id'];
		$db->sql_query($sql);
		$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
		$db->sql_query($sql);
		//if an empty parent class is left behind, get rid of it too
		while ($parent_id = $row['parent_id'])
		{
			$sql = 'SELECT * FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $parent_id;
			$result_2 = $db->sql_query($sql);
			$row = $db->sql_fetchrow($result_2);
			if ($row['left_id'] + 1 != $row['right_id'] or $row['module_langname'] == 'ACP_CAT_DOT_MODS')
			{
				break;
			}
			$sql = 'DELETE FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $row['module_id'];
			$db->sql_query($sql);
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET right_id = right_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND right_id > ' . $row['right_id'];
			$db->sql_query($sql);
			$sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = left_id - 2 WHERE module_class = \'' . $row['module_class'] . '\' AND left_id > ' . $row['right_id'];
			$db->sql_query($sql);
		}
	}
}
I recently tried the 3.0 queries, I don't know if that's what's causing this:
Shop Mod Installer

You shouldn't be seeing this. It means something is wrong with the installer. Let me know at phantom AT radoncube.com or post on the mod's topic on phpbb.com.
Let me drop the tables and retry the installer.

Re: [ALPHA] Shop Mod (0.4.0)

Posted: Fri Jun 20, 2008 2:24 am
by ihermit
I'm sorry, this will sound silly but which tables should I drop? :cry: