Tuesday, May 16, 2006

1 File Hacking (1)

1 File Hacking is a nickname for new customizing method of XOOPS Cube. It is realized by the pair of Preload and ActionFilter. Site owner uses it for pinpoint customizing.

Preload is the mechanism that the initialize-code is appended to the procedure of XOOPS Cube (Imagine .bat file of DOS). ActionFilter is the class that is like mojavi for initializing. In the latest 2.1 on CVS, the rule of Preload is the following:

  • AutoPreload of /setting/site_default.ini.php has to be true. But, you don't need to edit it because it's the default value.
  • Create a file whose extension is '.class.php'.
  • Define a class that extends XCube_ActionFilter in that file.
  • The class name has to equal the body name of that file.

I explain Preload of 1 File Hacking to you with a actual example. You know XOOPS Protector. GIJOE advises hacking mainfile.php for the maximum impact of XOOPS Protector. Let's create the file that works as well as hacked mainfile.php:

  1. Make 'ProtectorLoader.class.php' in XOOPS_ROOT_PATH/preload.
  2. Program the following code:

class ProtectorLoader extends XCube_ActionFilter
{
function
preFilter()
{
include(
XOOPS_ROOT_PATH . '/modules/protector/include/precheck.inc.php' ) ;
}

function
preBlockFilter()
{
include(
XOOPS_ROOT_PATH . '/modules/protector/include/postcheck.inc.php' ) ;
}
}


Mission Complete. This file is good to share. Site owner can tune up his site by such files after he installed some module.

Note:

You can handle this entry under X11 licence. But this entry depends on XOOPS Cube Alpha version that grows up everyday. You have to pay attention to the matter.
(In Japan, it's unpossible to cast aside author's copyright. But, X11 licence doesn't contradict the copyright laws of Japan.)

When official spec will be set up, official technical document will be published.

No comments: