/** Datei: functions/de.arunox.tools.translate.php **/ * @copyright 2020 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ if( !function_exists( "__" ) ) { function __( $string, ...$args ) : string { if( !is_string( $string ) ) return FALSE; $textDomain = "core"; $TRANSLATIONS = []; if( defined( "TRANSLATIONS" ) ) { $TRANSLATIONS = TRANSLATIONS; } // if( $string == "Card" ) show( $string, $textDomain ); if( isset( $TRANSLATIONS[ $textDomain ] ) && isset( $TRANSLATIONS[ $textDomain ][ $string ] ) ) { $string = $TRANSLATIONS[ $textDomain ][ $string ]; } $count = 0; $extra = [ "t", "T", "D" ]; $regex = '%(?:(\d+)\$)?(?:([^0-9$]+)\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?([bcdeEufFgGosxX' . implode("", $extra ) . '])'; $string = preg_replace_callback("/{$regex}/", function( $matches ) use( &$count, &$args, $extra ) { if( !$matches[1] ) $count = $count + 1; if( !in_array( $matches[3], $extra ) ) return $matches[0]; $matches[1] = is_numeric( $matches[1] ) ? $matches[1] : $count; $argument = $args[ $matches[1] - 1 ]; // show( $matches, $count, $args ); if( $matches[3] === "t" ) $args[] = __( $argument ); if( $matches[3] === "T" ) $args[] = __( ucfirst( $argument ) ); if( $matches[3] === "D" ) { if( !is_numeric( $argument ) ) $argument = strtotime( $argument ); if( defined( $matches[2] ) ) { $matches[2] = constant( $matches[2] ); } $argument = date( $matches[2], $argument ); // show( $matches ); $args[] = $argument; } $matches[1] = array_key_last( $args ) + 1; // show( $matches, $count, $args, FALSE ); return "%{$matches[1]}\$s"; }, $string ); // show( $textDomain, $string, TRANSLATIONS ); return sprintf( $string, ...$args ); } } if( !function_exists( "_d" ) ) { function _d( $string, $domain = "core", ...$args ) { $TRANSLATIONS = []; if( defined( "TRANSLATIONS" ) ) { $TRANSLATIONS = TRANSLATIONS; } if( isset( $TRANSLATIONS[ $domain ][ $string ] ) ) { $string = $TRANSLATIONS[ $domain ][ $string ]; } foreach( $args as &$arg ) { if( isset( $TRANSLATIONS[ $domain ][ $arg ] ) ) { $arg = $TRANSLATIONS[ $domain ][ $arg ]; } } return __( $string, ...$args ); } } if( !function_exists( "_ed" ) ) { function _ed( $string, ...$args ) { echo _d( $string, ...$args ); } } if( !function_exists( "_e" ) ) { function _e( $string, ...$args ) { echo __( $string, ...$args ); } } /** Datei: functions/de.arunox.tools.flush_json.php **/ * @copyright 2020 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ if( !function_exists( "flush_json" ) ) { function flush_json( $args, $code = 200 ) { header("Content-Type: application/json"); header("Cache-Control: no-cache"); header("X-Accel-Buffering: no"); echo json_encode( array_filter( $args ), JSON_UNESCAPED_UNICODE ); echo "\n"; flush(); } } /** Datei: functions/de.arunox.tools.http_error_code.php **/ * @copyright 2026 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ if( !function_exists( "http_error_code" ) ) { function http_error_code( int $response_code ) { http_response_code( $response_code ); exit; } } /** Datei: functions/de.arunox.tools.ftp_is_dir.php **/ * @copyright 2020 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ use FTP\Connection; if( !function_exists( "ftp_is_dir" ) ) { function ftp_is_dir( FTP\Connection $ftp, $dirname ) { if( ftp_nlist( $ftp, $dirname ) ) { return TRUE; } return FALSE; } } /** Datei: functions/de.arunox.tools.ftp_rmdir_recursive.php **/ * @copyright 2020 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ use FTP\Connection; if( !function_exists( "ftp_rmdir_recursive" ) ) { function ftp_rmdir_recursive( FTP\Connection $ftp, $dirname ) { $files = ftp_nlist( $ftp, $dirname ); $files = array_filter( $files, fn( $file ) => !preg_match( "/\/\.\.?$/", $file ) ); foreach( $files as $file ) { if( ftp_is_dir( $ftp, $file ) ) { ftp_rmdir_recursive( $ftp, $file ); } else ftp_delete( $ftp, $file ); } ftp_rmdir( $ftp, $dirname ); } }