device_dir = $myDevice->getDir(); $this->device_file = $myDevice->getFile(); parent::__construct( $myData ); $myFile = $this->getFile().".dbphp"; if ( ! is_file( $myFile ) ) file_put_contents( $myFile ,serialize( $this ) ); } public function getDevice() : Device { return unserialize( file_get_contents( $this->device_file ) ); } public function writeXml( $xml ,$child ) { $xmlMyRessource = $xml->createElement( "ressource" ); $xmlMyRessource->appendChild( $xml->createElement( "id", $this->id ) ); if ( is_array( $this->data ) ) foreach( $this->data as $key => $data ) $xmlMyRessource->appendChild( $xml->createElement( $key, $data ) ); $child->appendChild( $xmlMyRessource ); return $xmlMyRessource; } // /darkauth\db\auth\Ressource::listToXml( $xml ,$child ) public static function listToXml( $xml ,$child ) { $xmlRessources = $xml->createElement( "ressources" ); $child->appendChild( $xmlRessources ); foreach( scandir( \darkauth\db\auth\Ip::$ipsDir ) as $anValue ) if ( $anValue=="." || $anValue==".." ) continue; elseif ( is_dir( ( $anIpDir = \darkauth\db\auth\Ip::$ipsDir."/$anValue" ) ) ) foreach( scandir( $anIpDir ) as $anOtherValue ) if ( $anOtherValue=="." || $anOtherValue==".." ) continue; elseif ( is_dir( ( $anBrowserDir = "{$anIpDir}/{$anOtherValue}" ) ) ) foreach( scandir( $anBrowserDir ) as $anLastOtherValue ) if ( $anLastOtherValue=="." || $anLastOtherValue==".." ) continue; elseif ( is_dir( ( $anDeviceDir = "{$anBrowserDir}/{$anLastOtherValue}" ) ) ) foreach( scandir( $anDeviceDir ) as $anPoueLastOtherValue ) if ( $anPoueLastOtherValue=="." || $anPoueLastOtherValue==".." ) continue; elseif ( is_file( ( $serializedFile = "{$anDeviceDir}/{$anPoueLastOtherValue}" ) ) && \darkphp\string\DwString::endsWith( $serializedFile ,".dbphp" ) ) { //$xmlMyRessource = \StaticRootNameSpace::unserializeMyObj( file_get_contents( $serializedFile ),$xml ,$xmlRessources ); $xmlMyRessource = @unserialize( file_get_contents( $serializedFile ) )->writeXml( $xml, $xmlRessources ); //$xmlMyRessource->appendChild( $xml->createElement( "device_dir2", $anDeviceDir ) ); $brDirLength=strlen( $anDeviceDir ); $lastSlash = strrpos( $anDeviceDir ,"/" ); $dev_dirid = substr( $anDeviceDir ,$lastSlash + 8 ); $xmlMyRessource->appendChild( $xml->createElement( "dev_dirid" ,$dev_dirid ) ); $xmlMyRessource->setAttribute("dev_dirid" ,$dev_dirid ); $secondLastSlash = strrpos( $anDeviceDir ,"/", $lastSlash - $brDirLength - 1 ); $browser_dirid=substr( $anDeviceDir ,$secondLastSlash + 9, $lastSlash-$secondLastSlash-9 ); $xmlMyRessource->appendChild( $xml->createElement( "browser_dirid" ,$browser_dirid ) ); $xmlMyRessource->setAttribute("browser_dirid" ,$browser_dirid ); $thirdLastSlash = strrpos( $anDeviceDir ,"/", $secondLastSlash - $brDirLength - 1 ); $ip_dirid=substr( $anDeviceDir ,$thirdLastSlash + 4, $secondLastSlash-$thirdLastSlash-4 ); $xmlMyRessource->appendChild( $xml->createElement( "ip_dirid" ,$ip_dirid ) ); $xmlMyRessource->setAttribute("ip_dirid" ,$ip_dirid ); } return $xmlRessources; } public function getFile() : string { return $this->device_dir."/".$this->id; } // \darkauth\db\Ressource::fromApache2( $myDevice ,$_SERVER ); public static function fromApache2( Device $myDevice ,$myServer ) : ?self { return new self( $myDevice ,array( "method" => $myServer['REQUEST_METHOD'] ,"uri" => $myServer['REQUEST_URI'] ,"query" => $myServer['QUERY_STRING'] ) ); } } ?>