This will allow each of nine middleboxes to be activated for one of the seven page positions. If 'Middleboxes - Homepage Only?' is set to 0, positions 4 through 7 would be able to display on internal category listing pages (useful when tpl_index_default is active on the homepage).
The middleboxes active in each position will display in numeric order within that section.

This line and its closing } are only needed in tpl_index_categories.php, since tpl_index_default.php is never used elsewhere than the homepage.
PHP Code:
if($this_is_home_page or !MIDDLEBOX_HOME) {//only in tpl_index_categories.php 
I have not tested this code, so I would appreciate feedback on how it works when put into the files (and if it doesn't work, we can work on debugging:). Look over the SQL carefully, as I'm not sure I understand it well enough to have edited it correctly.