"; list( $anHash ,$anMail ) = explode( ':' ,$line); if ( $anHash == $mailId ) { $theMail = $anMail; break; } } return $theMail; } // \darkauth\db\Users::getUserMailFor( $mailId ); public static function getHashMailFor( string $mail ) : string { $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( self::$userIdFile ) ) ); $theHash=""; foreach( $lines as $line ) { if ( empty( $line ) ) continue; //echo "search:$line
"; list( $anHash ,$anMail ) = explode( ':' ,$line); if ( $anMail == $mail ) { $theHash = $anHash; break; } } return $theHash; } // \darkauth\db\Users::removeAccountFromMail( $mailId ); public static function removeAccountFromMail( string $mail ) : void { $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( self::$userIdFile ) ) ); $newUserFileContent = ""; foreach( $lines as $line ) { if ( empty( $line ) ) continue; list( $anHash ,$anMail ) = explode( ':' ,$line); if ( $anMail == $mail ) continue; else $newUserFileContent.=$line.\PHP_EOL; } file_put_contents( self::$userIdFile ,$newUserFileContent ); $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( self::$userPassFile ) ) ); $newPassFileContent=""; foreach( $lines as $line ) { if ( empty( $line ) ) continue; //echo "search:$line
"; list($anMail ,$anUser, $anPass ,$anPresent ) = explode( ':' ,$line); if ( $anMail == $mail ) continue; else $newPassFileContent.=$line.\PHP_EOL; } file_put_contents( self::$userPassFile ,$newPassFileContent ); } // \darkauth\db\Users::addAccount( $uuid ,$mail, $apacheUser, $apachePass, $userPresent ); public static function addAccount( string $uuid ,string $mail ,string $apacheUser ,string $apachePass ,string $userPresent ) : void { $resource = \fopen( self::$userIdFile ,'a' ); $toWrite=implode( ':' ,array( $uuid ,$mail ) ).\PHP_EOL; if ( \fwrite( $resource, $toWrite, strlen( $toWrite ) ) ) { echo "Passe 1/2 du compte enregistrer.
".\PHP_EOL; } else echo "Désolé, l'enregistrement a échoué, contactez-nous.
".\PHP_EOL; \fflush($resource); \fclose($resource); $resource = \fopen( self::$userPassFile ,'a' ); $toWrite=implode( ':' ,array( $mail,$apacheUser ,$apachePass,$userPresent ) ).\PHP_EOL; if ( fwrite( $resource, $toWrite, strlen( $toWrite ) ) ) { echo "Passe 2/2 du compte enregistrer.
".\PHP_EOL; } else echo "Désolé, l'enregistrement a échoué, contactez-nous.
".\PHP_EOL; \fflush($resource); \fclose($resource); } // \darkauth\db\Users::getUserFor( $mail ); public static function getUserFor( string $mailToSearch ) : ?array { $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( self::$userPassFile ) ) ); $theUser=null; $mail = strtolower( $mailToSearch ); foreach( $lines as $line ) { if ( empty( $line ) ) continue; //echo "search:$line
"; list($anMail ,$anUser, $anPass ,$anPresent ) = explode( ':' ,$line); if ( $anMail == $mail ) { $theUser = array( $anUser ,$anPass ,$anPresent ); break; } } return $theUser; } // \darkauth\db\Users::getUserForHtPass( $user, $pass ); public static function getUserForHtPass( string $user, string $pass ) : ?string { $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( self::$userPassFile ) ).\PHP_EOL ); //echo "content:".file_get_contents( self::$userPassFile ); $theMail=null; foreach( $lines as $line ) { //echo "line: $line"; if ( empty( $line ) ) continue; list($anMail ,$anUser, $anPass ,$anPresent ) = explode( ':' ,$line); if ( $anUser == $user && $anPass == $pass ) { $theMail = $anMail; break; } //else // echo "search:$anUser == $user $anPass == $pass
".\PHP_EOL; } return $theMail; } // \darkauth\db\Users::searchUserInPasswd( $passFile ,$user ); function searchUserInPasswd( string $passFile ,string $user ) : bool { $found=false; if ( is_file( $passFile ) ) { //echo "search:$passFile
".\PHP_EOL; $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( $passFile ) ) ); foreach( $lines as $line ) { if ( empty( $line ) ) continue; //echo "search:$line
"; list($anUser, $anHash) = explode( ':' ,$line); //echo "search:$anUser
"; if ( $user == $anUser ) { $found=true; break; } } } return $found; } /* // \darkauth\db\Users::searchUserPassInPasswd( $passFile ,$user ); public static function searchUserPassInPasswd( string $passFile ,string $user ) : ?string { $found=null; if ( is_file( $passFile ) ) { //echo "search:$passFile
".\PHP_EOL; $lines = preg_split( '/\r\n|\n|\r/' ,trim( file_get_contents( $passFile ) ) ); foreach( $lines as $line ) { if ( empty( $line ) ) continue; //echo "search:$line
"; list($anUser, $anHash) = explode( ':' ,$line); //echo "search:$anUser
"; if ( $user == $anUser ) { $found=$anHash; break; } } } return $found; } //*/ } \darkauth\db\Users::init(); ?>