..cool, we will make a new module and not just some new module, nope let's make a fully automatic injection script! This tutorial is the first step into making this. Let's first explain..
<?php
/*
Set and gets modules
Author: Remco Kouw
Site: http://www.hacksuite.com
Last Edit: 12-11-2014
*/
if(!defined('IN_SCRIPT')){
exit;
}
if(false!==($aDirs = GetDirByDir($_PATHS['root']."/Modules",0))){
for($x=0;$x<count($aDirs);$x++){
// modules start with 'thc_'
if(substr($aDirs[$x],0,4)=="thc_"){
// get the properties for the module
$sSetup = $_PATHS['root']."/Modules/".$aDirs[$x]."/setup.php";
if(file_exists($sSetup)){
include_once($sSetup);
if(!isset($_CONTEXT['modcats'][$aProperties['category']])){
$_CONTEXT['modcats'][$aProperties['category']] = array();
}
$_CONTEXT['modcats'][$aProperties['category']][] = array($aDirs[$x],$aProperties['name']);
$_CONTEXT['modules'][$aDirs[$x]] = $aProperties;
if(!isset($_CONTEXT['modules'][$aDirs[$x]])){
// make sure the module dir can be used as array key
die("Invalid module name, make sure it matches this pattern: thc_[a-zA-Z0-9_]{2,3}");
}
}
else{
die("No setup file present for module <b>".$aDirs[$x]."</b>");
}
}
}
}
// request for module, if it exists set it as default to make sure we are working with the right modules
if(isset($_GET['module']) || defined('SCREEN')){
$_GET['module'] = (!isset($_GET['module']) ? $_MODULE_C : $_GET['module']);
if(isset($_CONTEXT['modules'][$_GET['module']])){
// set as current module
$_CONTEXT['module_current'] = $_GET['module'];
// default module root
$_PATHS['module_default_root'] = $_PATHS['root']."/Modules/".$_CONTEXT['module_current'];
// default module root http
$_PATHS['module_default_root_http'] = $_PATHS['root_http']."/Modules/".$_CONTEXT['module_current'];
// set sub title
$_CONTEXT['subtitle'] = $_CONTEXT['modules'][$_GET['module']]['name'];
}
}
?>