*/ class ParTCP_Server { public $fileSystem; public $options; public $objects; public function __construct( $fileSystem, $options = [] ){ $this->fileSystem = $fileSystem; $this->options = $options; $this->objects = []; } public function register_object( $callback, $name ){ $this->objects[] = [ $callback, $name ]; } public function get_dir( $absolute = FALSE ){ return ''; } public function get_data(){ if ( ! $this->fileSystem->exists('_def') ){ return FALSE; } $data = $this->fileSystem->get_recent_contents( '_def', "[0-9]*" ); if ( empty( $data ) ){ return FALSE; } $receipt = yaml_parse( $data ); if ( empty( $receipt['Server-Data'] ) ){ return FALSE; } $data = $receipt['Server-Data']; if ( empty( $data['name'] ) ){ $data['name'] = $_SERVER['SERVER_NAME']; } return $data; } public function get_objects(){ $result = []; foreach ( $this->objects as $object ){ $data = call_user_func( $object[0] ); if ( $data ){ $result[ $object[1] ] = $data; } } return $result; } public function purge_data( $data ){ $validKeys = [ 'name', 'community', 'modules', 'locale', 'consent_statement', 'privacy_notice', 'key_manager', 'auth_service', 'short_code', 'description' ]; return array_filter( $data, function( $k ) use ( $validKeys ){ return in_array( $k, $validKeys ) || substr( $k, 0, 4 ) == 'mod.'; }, ARRAY_FILTER_USE_KEY ); } } // end of file server.class.php