/** * @see EventHandlerInterface::__construct() * @param object $event_object */ function __construct($event_object) { if (is_object($event_object)) { $event_listener_array = BaseEventListener_Access::list_classes(); if (is_array($event_listener_array) and count($event_listener_array) >= 1) { foreach ($event_listener_array as $key => $class) { if (($listen_success = $class::listen_events($event_object)) == false) { break; } } if ($listen_success == true) { $this->success = true; } } } }
private function register_includes() { if (is_array($this->include_folders) and count($this->include_folders) >= 1) { $registered_include_array = BaseInclude_Access::list_folder_entries(); $found_include_array = array(); $include_requirements_array = array(); foreach ($this->include_folders as $key => $value) { $config_folder = $value . "/config"; if (is_dir($config_folder)) { $config_file = $config_folder . "/include_info.php"; if (is_file($config_file)) { require $config_file; $class_event_listener_file = $config_folder . "/class_event_listener.php"; if (!is_file($class_event_listener_file)) { unset($class_event_listener_file); } $db_table_name_file = $config_folder . "/db_table_name.php"; if (!is_file($db_table_name_file)) { unset($db_table_name_file); } $class_path_file = $config_folder . "/class_path.php"; if (!is_file($class_path_file)) { unset($class_path_file); } if (($register_key = array_search(str_replace(constant("INCLUDE_DIR") . "/", "", $value), $registered_include_array)) !== false) { $found_include_array[$register_key] = str_replace(constant("INCLUDE_DIR") . "/", "", $value); if (isset($db_table_name_file)) { $db_table_name_checksum = BaseIncludeFile_Access::get_checksum_by_include_id_and_name($register_key, "db_table_name.php"); if ($db_table_name_checksum != md5_file($db_table_name_file)) { $db_table_name_id = BaseIncludeFile_Access::get_id_by_include_id_and_name($register_key, "db_table_name.php"); if ($db_table_name_id != null) { $base_include_file = new BaseIncludeFile_Access($db_table_name_id); $base_include_file->set_checksum(md5_file($db_table_name_file)); } else { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($register_key, "db_table_name.php", md5_file($db_table_name_file)) == null) { throw new BaseIncludeProcessFailedException(); } } } } if (isset($class_event_listener_file)) { $class_event_listener_checksum = BaseIncludeFile_Access::get_checksum_by_include_id_and_name($register_key, "class_event_listener.php"); if ($class_event_listener_checksum != md5_file($class_event_listener_file)) { require $class_event_listener_file; if (BaseEventListener_Access::delete_by_include_id($register_key) == false) { throw new BaseIncludeProcessFailedException(); } // Register Event Handler if (is_array($event_listener) and count($event_listener) >= 1) { foreach ($event_listener as $event_listener_key => $event_listener_value) { $base_event_listener = new BaseEventListener_Access(null); if ($base_event_listener->create($register_key, $event_listener_value) == null) { throw new BaseEventHandlerCreationFailedException(); } } } $class_event_listener_id = BaseIncludeFile_Access::get_id_by_include_id_and_name($register_key, "class_event_listener.php"); if ($class_event_listener_id != null) { $base_include_file = new BaseIncludeFile_Access($class_event_listener_id); $base_include_file->set_checksum(md5_file($class_event_listener_file)); } else { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($register_key, "class_event_listener.php", md5_file($class_event_listener_file)) == null) { throw new BaseIncludeProcessFailedException(); } } } } if (isset($class_path_file)) { $class_path_checksum = BaseIncludeFile_Access::get_checksum_by_include_id_and_name($register_key, "class_path.php"); if ($class_path_checksum != md5_file($class_path_file)) { $class_path_id = BaseIncludeFile_Access::get_id_by_include_id_and_name($register_key, "class_path.php"); if ($class_path_id != null) { $base_include_file = new BaseIncludeFile_Access($class_path_id); $base_include_file->set_checksum(md5_file($class_path_file)); } else { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($register_key, "class_path.php", md5_file($class_path_file)) == null) { throw new BaseIncludeProcessFailedException(); } } } } } else { // Register new includes if (is_array($requires) and count($requires) >= 1) { $include_requirements_array[str_replace(constant("INCLUDE_DIR") . "/", "", $value)] = $requires; } // Register includes $base_include = new BaseInclude_Access(null); if (($base_include_id = $base_include->create($name, str_replace(constant("INCLUDE_DIR") . "/", "", $value))) == null) { throw new BaseIncludeProcessFailedException(); } else { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($base_include_id, "include_info.php", md5_file($config_file)) == null) { throw new BaseIncludeProcessFailedException(); } } if (isset($db_table_name_file)) { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($base_include_id, "db_table_name.php", md5_file($db_table_name_file)) == null) { throw new BaseIncludeProcessFailedException(); } } if (isset($class_event_listener_file)) { require $class_event_listener_file; $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($base_include_id, "class_event_listener.php", md5_file($class_event_listener_file)) == null) { throw new BaseIncludeProcessFailedException(); } // Register Event Handler if (is_array($event_listener) and count($event_listener) >= 1) { foreach ($event_listener as $event_listener_key => $event_listener_value) { $base_event_listener = new BaseEventListener_Access(null); if ($base_event_listener->create($base_include_id, $event_listener_value) == null) { throw new BaseEventHandlerCreationFailedException(); } } } } if (isset($class_path_file)) { $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($base_include_id, "class_path.php", md5_file($class_path_file)) == null) { throw new BaseIncludeProcessFailedException(); } } $found_include_array[$register_key] = str_replace(constant("INCLUDE_DIR") . "/", "", $value); } unset($name); unset($requires); unset($event_listener); } } } // Past Requirements Check $registered_include_array = BaseInclude_Access::list_folder_entries(); if (is_array($registered_include_array) and count($registered_include_array) >= 1) { foreach ($registered_include_array as $key => $value) { if (isset($include_requirements_array[$value]) and is_array($include_requirements_array[$value]) and count($include_requirements_array[$value]) >= 1) { foreach ($include_requirements_array[$value] as $sub_key => $sub_value) { if (!in_array($sub_value, $registered_include_array)) { throw new BaseIncludeRequirementFailedException(); } } } } } // Delete legacy includes $legacy_include_array = array_diff($registered_include_array, $found_include_array); if (is_array($legacy_include_array) and count($legacy_include_array) >= 1) { foreach ($legacy_include_array as $legacy_key => $legacy_value) { if (BaseIncludeFile_Access::delete_by_include_id($legacy_key) == false) { throw new BaseIncludeProcessFailedException(); } if (BaseEventListener_Access::delete_by_include_id($legacy_key) == false) { throw new BaseIncludeProcessFailedException(); } $include_delete_event = new IncludeDeleteEvent($legacy_key); $event_handler = new EventHandler($include_delete_event); if ($event_handler->get_success() == false) { throw new BaseIncludeProcessFailedException(); } $base_include = new BaseInclude_Access($legacy_key); if ($base_include->delete() == false) { throw new BaseIncludeProcessFailedException(); } } } // Register Executes $registered_include_array = BaseInclude_Access::list_folder_entries(); if (is_array($registered_include_array) and count($registered_include_array) >= 1) { foreach ($registered_include_array as $key => $value) { $register_execute = "core/include/" . $value . "/config/register_execute.php"; if (is_file($register_execute)) { $register_execute_checksum = BaseIncludeFile_Access::get_checksum_by_include_id_and_name($key, "register_execute.php"); if ($register_execute_checksum != md5_file($register_execute)) { require $register_execute; if ($result == true) { BaseIncludeFile_Access::delete_by_include_id_and_name($key, "register_execute.php"); $base_include_file = new BaseIncludeFile_Access(null); if ($base_include_file->create($key, "register_execute.php", md5_file($register_execute)) == null) { throw new BaseIncludeProcessFailedException(); } } else { throw new BaseIncludeProcessFailedException(); } unset($result); } } } } } }