<?php
/*
* Secure Lab Project, 2012, Alfa 1.
* FOR PUBLIC TESTING; VERSION 0.1.67 Alfa 1.
*
* Alexander Belov (c) securelab.sourceforge.net
*
* This file is general controller of system.
*
* Information about this file:
*
* @name securelab-main.php
* @class SecureLab / Main class
* @package Secure Lab PHP Lib
* @author Alexander Belov (c)
* @site securelab.sourceforge.net
* @support sourceforge.net/p/securelab/tickets/
* @ver from 3/10/2012
*
*/
class SecureLab {
private $TemporaryData;
public function __construct() {
session_start();
define( "SECURELAB_DIRECTORY", dirname( __FILE__ ) . "\\" );
global $_SecureLabMainClass;
$_SecureLabMainClass = $this;
@ $this->SL_StoreObject ( "development/logs" );
@ $this->SL_StoreObject ( "development/tools" );
@ $this->SL_StoreObject ( "development/addons" );
@ $this->SL_StoreObject ( "forms/securitycore" );
@ $this->SL_StoreObject ( "configuration/class" );
@ $this->SL_StoreObject ( "filtering/filtering" );
@ $this->SL_StoreObject ( "filtering/get/class" );
@ $this->SL_StoreObject ( "filtering/post/class" );
( @ $this->Configuration->ConfigurationKey("SYSTEM:ALLOW_DEBUGGING_AFTER_INIT") == 0 ? ( $_SecureLabMainClass = null ) : null );
@ $this->TemporaryData["Settings"]["UseClassAsFunction"] = ( @ $this->Configuration->ConfigurationKey( "SYSTEM:ALLOW_USE_AS_FUNCTION" ) == 1 ? 1 : 0 );
@ $this->Configuration->SL_LockConfigurationAccess();
}
private function SL_StoreObject( $ObjectToStore ) {
$RegisteredObjects = array (
"development/logs" => array( "FileDirectory" => "securelab-dumpapi.php",
"ObjectClassName" => "SecureLabDumpAPI",
"SystemObjectName" => "DumpAPI" ),
"development/tools" => array( "FileDirectory" => "securelab-developer.php",
"ObjectClassName" => "SecureLabDeveloper",
"SystemObjectName" => "DeveloperTools" ),
"development/addons" => array( "FileDirectory" => "securelab-addons.php",
"ObjectClassName" => "SecureLabAddonsManager",
"SystemObjectName" => "AddonsManager" ),
"configuration/class" => array( "FileDirectory" => "securelab-configuration.php",
"ObjectClassName" => "SecureLabConfigurationManager",
"SystemObjectName" => "Configuration" ),
"filtering/filtering" => array( "FileDirectory" => "securelab-filters.php",
"ObjectClassName" => "SecureLabFilters",
"SystemObjectName" => "FiltersAPI" ),
"forms/securitycore" => array( "FileDirectory" => "securelab-forms.php",
"ObjectClassName" => "SecureLabFormsProtector",
"SystemObjectName" => "FormsProtection" ),
"filtering/get/class" => array( "FileDirectory" => "securelab-get.php",
"ObjectClassName" => "GetDataHandler",
"ImportAsVariable" => true,
"SystemObjectName" => "GET" ),
"filtering/post/class" => array( "FileDirectory" => "securelab-post.php",
"ObjectClassName" => "PostDataHandler",
"ImportAsVariable" => true,
"SystemObjectName" => "POST" )
);
try {
if( ! $RegisteredObjects[ $ObjectToStore ] ) {
throw new Exception( "Object \"" . $ObjectToStore . "\" is not registered in system" );
}
if ( $this->$RegisteredObjects[ $ObjectToStore ][ "SystemObjectName" ] ) {
throw new Exception( "Object \"" . $ObjectType . "\" is already loaded into the system" );
return true;
}
if ( array_key_exists( $ObjectToStore, $RegisteredObjects ) ) {
if( @include_once( SECURELAB_DIRECTORY . $RegisteredObjects[ $ObjectToStore ][ "FileDirectory" ] ) ) {
if ( $RegisteredObjects[ $ObjectToStore ][ "ImportAsVariable" ] == true ) {
if( $RegisteredObjects[ $ObjectToStore ][ "SystemObjectName" ] == "GET" ) {
global $_GET;
@ $_GET = new $RegisteredObjects[ $ObjectToStore ][ "ObjectClassName" ]( $_GET );
}
if( $RegisteredObjects[ $ObjectToStore ][ "SystemObjectName" ] == "POST" ) {
global $_POST;
@ $_POST = new $RegisteredObjects[ $ObjectToStore ][ "ObjectClassName" ]( $_POST );
}
} else {
@ $this->$RegisteredObjects[ $ObjectToStore ][ "SystemObjectName" ] = new $RegisteredObjects[ $ObjectToStore ][ "ObjectClassName" ]();
return true;
}
} else {
throw new Exception( "Cannot to load object " . $ObjectType );
return false;
}
} else {
throw new Exception( "Calling of not defined object " . $ObjectType . ", line " . __LINE__ );
return false;
}
} catch ( Exception $ErrorMsg ) {
@ $this->DumpAPI->CreateDumpEvent( array(
"ErrorReporterFile" => __FILE__,
"ErrorReporterMessage" => $ErrorMsg->getMessage(),
"ErrorOccuredObject" => __METHOD__,
"ErrorIncomingEvent" => $ObjectToStore,
"ErrorFileLine" => __LINE__
) );
}
}
public function __invoke( $ExpectedAction ) {
try {
if( @ $this->TemporaryData["Settings"]["UseClassAsFunction"] == 1 ) {
switch( $ExpectedAction ) {
case "newformkey":
return $this->FormsProtection->NewProtectionKeys();
$Found = true;
break;
case "validateform":
return $this->FormsProtection->ValidateProtection();
$Found = true;
break;
case "printerrors":
print $this->DumpAPI->AccessGlobalDump();
$Found = true;
break;
case "printdebugtime":
$Found = true;
break;
}
if( $Found != true ) {
if( @ $this->AddonsManager->AddonExists( $ExpectedAction ) ) {
@ $this->AddonsManager->RunAddon( $ExpectedAction );
}
}
return true;
} else {
throw new Exception("System disallowing to use main class as function.");
}
} catch( Exception $ErrorMsg ) {
@ $this->DumpAPI->CreateDumpEvent( array (
"ErrorReporterFile" => __FILE__,
"ErrorReporterMessage" => $ErrorMsg->getMessage(),
"ErrorOccuredObject" => __METHOD__,
"ErrorIncomingEvent" => $ExpectedAction,
"ErrorFileLine" => __LINE__
) );
}
}
}
?>