1
dejadingo
PRECHECK resursion in protector
  • 2014/12/15 0:36

  • dejadingo

  • Just popping in

  • Posts: 71

  • Since: 2004/10/22


Here's one I did not expect to find.
I'm testing out a new site using Xoops 2.5.7.1 (PHP 5.4.27) and I have installed the Common Utilities (2.2.75) so that I can try out bitcero's QuickPages. The problem I have encountered comes when you try to hide the Common Utilities module from the Main Menu. In the protector's precheck.inc.php we find:
require_once dirname(__FILE__).'/precheck_functions.php' ;

  if( 
class_exists'Database' ) ) {
     require 
dirname(__FILE__).'/postcheck.inc.php' ;
     return ; }

  
define('PROTECTOR_PRECHECK_INCLUDED' ) ;

When I hide other modules like User Profile, or Private Messaging, it does not appear that the Database class exists, so we turn on PROTECTOR_PRECHECK_INCLUDED, and proceed with the rest of the code in that file. When hiding Common Utilities, the Database class apparently exists, and we try to load the postcheck.inc.php file. Unfortunately this starts an infinite recursion because PROTECTOR_PRECHECK_INCLUDED has not yet been defined and we go back to loading precheck.inc.php.

If I change precheck.inc.php to move
define('PROTECTOR_PRECHECK_INCLUDED' ) ;
above the check for the Database class, this gets the flag set before we need it to prevent the resursion.

2
dejadingo
Re: PRECHECK resursion in protector
  • 2014/12/15 15:47

  • dejadingo

  • Just popping in

  • Posts: 71

  • Since: 2004/10/22


It also seems we need to add the protection
if (defined('PROTECTOR_{PRE|POST}CHECK_INCLUDED')) return;

at the top of both precheck.inc.php and postcheck.inc.php to avoid the constant page error for trying to redefine PROTECTOR_POSTCHECK_INCLUDED since both of these files are also included by functions in core.php.

3
geekwright
Re: PRECHECK resursion in protector

There are some ramifications to this situation that will take a bit more than an 'if defined' to fix. I'm looking into it.

Thanks!

4
bitcero
Re: PRECHECK resursion in protector
  • 2014/12/15 19:47

  • bitcero

  • Quite a regular

  • Posts: 318

  • Since: 2005/11/26


Due to nature of rmcommon, it can not be hidden from active menus. If you wish to use the block "main menu" then is preferable to hide rmcommon directly from the template of this block.

You can edit the file "modules/system/templates/blocks/system_block_mainmenu.html" and change the content from this:

<div id="mainmenu">
    <
class="menuTop <{if !$block.nothome}>maincurrent<{/if}>" href="<{xoAppUrl }>" title="<{$block.lang_home}>"><{$block.lang_home}>a>
    
    <{foreach 
item=module from=$block.modules}>
        <
class="menuMain <{if $module.highlight}>maincurrent<{/if}>" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>"><{$module.name}>a>
        <{foreach 
item=sublink from=$module.sublinks}>
            <
class="menuSub" href="<{$sublink.url}>" title="<{$sublink.name}>"><{$sublink.name}>a>
        <{/foreach}>
    <{/foreach}>
    
div>


to this:

<div id="mainmenu">
    <
class="menuTop <{if !$block.nothome}>maincurrent<{/if}>" href="<{xoAppUrl }>" title="<{$block.lang_home}>"><{$block.lang_home}>a>
    
    <{foreach 
item=module from=$block.modules}>
    <{if 
$module.dirname!='rmcommon'}>
        <
class="menuMain <{if $module.highlight}>maincurrent<{/if}>" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>"><{$module.name}>a>
        <{foreach 
item=sublink from=$module.sublinks}>
            <
class="menuSub" href="<{$sublink.url}>" title="<{$sublink.name}>"><{$sublink.name}>a>
        <{/foreach}>
    <{/if}>
    <{/foreach}>
    
div>



Login

Who's Online

291 user(s) are online (182 user(s) are browsing Support Forums)


Members: 0


Guests: 291


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits