hU Y@hUshUhU@/hU P`hU 0QhU0@PhU@@.hUpPP`hUP``QhU`PphUp@4hU@4hU/ hU=hU<hU4hU@+phUp>hUH`RhUP p0ThUPPtphU<hUH 0RhUHp0ThUPtphU<hUHXRhUpp0ThUPtphU<hUHRhUp0ThUPtphU< hU`=hU<hU0 RhU  0RhU0phU@<hU@PphUP`G hU=hUp<hUpRhURhUp(phU<p hUP`H hU@8=hU<hU@RhUXRhUpphU<@hU{hU`H9hU`H hU= hU=hU<IhUPuhU<` hU  GhU8( phU0<p hU0 H hU=@ChUPAhU@<p hU@ HhU `HThUP` hU0`=@ChUPPAhUP`uhU`<UhUP`hU {ARhUp0ThUPt0ThU`tP~hUPpBphU<hUhpphU<UhU`hUh0phU<UhUp hU0=@ChUPA@ChU`AhU<UhUhUhphU<UhUhUh@phU <UhU hU hUp =hUPuhUPhUP`AphU`UhU` hU`@(=:hUPCphUUhUhU{hU`+hUQThUhUH`0pP~hU`PBhU<` hU jGhUH@phU<p hUHhUHhUhPphU<p hUHectory( $dirpath ) { $dirpath = (string) $dirpath; $file_exists = file_exists( $dirpath ); $is_writable = wp_is_writable( $dirpath ); // If the configured setting path exists and is writeable, use it. if ( $file_exists && $is_writable ) { return $dirpath; } // Otherwise, try and log default errors. if ( ! $file_exists ) { $this->log( 'The defined logging directory does not exist: ' . $dirpath, __METHOD__, 'error' ); } if ( ! $is_writable ) { $this->log( 'The defined logging directory exists but could not be written to: ' . $dirpath, __METHOD__, 'error' ); } return false; } /** * Returns the directory to use for logging if not defined by Config. Creates one if it doesn't exist. * * Note: Created directories are protected by an index.html file to prevent browsing. * * @return false|string Directory path, if exists; False if failure. */ private function maybe_make_logging_directory() { $upload_dir = wp_upload_dir(); $log_dir = trailingslashit( $upload_dir['basedir'] ) . self::DIRECTORY_PATH; // Directory exists; return early. if ( file_exists( $log_dir ) ) { return $log_dir; } // Create the folder using wp_mkdir_p() instead of relying on KLogger. $folder_created = wp_mkdir_p( $log_dir ); // Something went wrong mapping the directory. if ( ! $folder_created ) { $this->log( 'The log directory could not be created: ' . $log_dir, __METHOD__, 'error' ); return false; } return $log_dir; } /** * Prevent browsing a directory by adding an index.html file to it * * Code inspired by @see wp_privacy_generate_personal_data_export_file() * * @param string $dirpath Path to directory to protect (in this case, logging). * * @return bool True: File exists or was created; False: file could not be created. */ private function prevent_directory_browsing( $dirpath ) { // phpcs:disable Generic.Commenting.DocComment.MissingShort /** @global WP_Filesystem_Base $wp_filesystem */ global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { $this->log( 'Unable to initialize WP_Filesystem.', __METHOD__, 'error' ); return false; } // Protect export folder from browsing. $index_pathname = $dirpath . 'index.html'; if ( $wp_filesystem->exists( $index_pathname ) ) { return true; } $file_content = ''; $file_was_saved = $wp_filesystem->put_contents( $index_pathname, $file_content ); if ( ! $file_was_saved ) { $this->log( 'Unable to protect directory from browsing.', __METHOD__, 'error' ); return false; } return true; } /** * Returns whether logging is enabled * * @return bool */ public function is_enabled() { $is_enabled = ! empty( $this->logging_enabled ); /** * Filter: Whether debug logging is enabled in TrustedLogin Client * * @since 1.0.0 * * @param bool $debug_mode Default: false */ $is_enabled = apply_filters( 'trustedlogin/' . $this->ns . '/logging/enabled', $is_enabled ); return (bool) $is_enabled; } /** * Log a message using KLogger or error_log(). * * @see https://github.com/php-fig/log/blob/master/Psr/Log/LogLevel.php for log levels * * @param string|\WP_Error $message Message or error to log. If a WP_Error is passed, $data is ignored. * @param string $method Method where the log was called. * @param string $level PSR-3 log level. * @param \WP_Error|\Exception|mixed $data Optional. Error data. Ignored if $message is WP_Error. */ public function log( $message = '', $method = '', $level = 'debug', $data = array() ) { if ( ! $this->is_enabled() ) { return; } $levels = array( 'emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug' ); if ( ! in_array( $level, $levels, true ) ) { $this->log( sprintf( 'Invalid level passed by %s method: %s', $method, $level ), __METHOD__, 'error' ); $level = 'debug'; // Continue processing original log. } $log_message = $message; if ( is_wp_error( $log_message ) ) { $data = $log_message; // Store WP_Error as extra data. $log_message = ''; // The message will be constructed below. } if ( ! is_string( $log_message ) ) { // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r $log_message = print_r( $log_message, true ); } if ( is_wp_error( $data ) ) { $log_message .= sprintf( '[%s] %s', $data->get_error_code(), $data->get_error_message() ); } if ( $data instanceof \Exception ) { $log_message .= sprintf( '[%s] %s', $data->getCode(), $data->getMessage() ); } // Keep PSR-4 compatible. if ( $data && ! is_array( $data ) ) { $data = array( $data ); } do_action( 'trustedlogin/' . $this->ns . '/logging/log', $message, $method, $level, $data ); do_action( 'trustedlogin/' . $this->ns . '/logging/log_' . $level, $message, $method, $data ); // If logging is in place, don't use the error_log. if ( has_action( 'trustedlogin/' . $this->ns . '/logging/log' ) || has_action( 'trustedlogin/' . $this->ns . '/logging/log_' . $level ) ) { return; } // Set up klogger, creating the logging file/directory if it doesn't already exist. $this->klogger = $this->setup_klogger( $this->config ); // The logger class didn't load. Rely on WordPress logging, if enabled. if ( ! $this->klogger ) { $wp_debug = defined( 'WP_DEBUG' ) && WP_DEBUG; $wp_debug_log = defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG; // If WP_DEBUG and WP_DEBUG_LOG are enabled, log errors to that file. if ( $wp_debug && $wp_debug_log ) { if ( ! empty( $data ) ) { // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r $log_message .= ' Error data: ' . print_r( $data, true ); } // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_error_log error_log( $method . ' (' . $level . '): ' . $log_message ); } return; } $this->klogger->{$level}( $log_message, (array) $data ); } } {"id":4555,"date":"2025-05-22T06:15:00","date_gmt":"2025-05-22T04:15:00","guid":{"rendered":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030.jpg"},"modified":"2025-05-22T06:15:00","modified_gmt":"2025-05-22T04:15:00","slug":"img-20250518-wa0030","status":"inherit","type":"attachment","link":"https:\/\/www.tierhilfeweidenberg.de\/en\/img-20250518-wa0030\/","title":{"rendered":"IMG-20250518-WA0030"},"author":2,"featured_media":0,"comment_status":"","ping_status":"closed","template":"","meta":{"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false},"class_list":["post-4555","attachment","type-attachment","status-inherit","hentry"],"translation":{"provider":"WPGlobus","version":"3.0.3","language":"en","enabled_languages":["de","en"],"languages":{"de":{"title":true},"en":{"title":false}}},"description":{"rendered":"

\"\"<\/a><\/p>\n"},"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/jpeg","media_details":{"width":946,"height":1313,"file":"2025\/05\/IMG-20250518-WA0030.jpg","filesize":323953,"sizes":{"medium":{"file":"IMG-20250518-WA0030-216x300.jpg","width":216,"height":300,"filesize":15149,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030-216x300.jpg"},"large":{"file":"IMG-20250518-WA0030-738x1024.jpg","width":738,"height":1024,"filesize":113865,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030-738x1024.jpg"},"thumbnail":{"file":"IMG-20250518-WA0030-150x150.jpg","width":150,"height":150,"filesize":6491,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030-150x150.jpg"},"medium_large":{"file":"IMG-20250518-WA0030-768x1066.jpg","width":768,"height":1066,"filesize":121097,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030-768x1066.jpg"},"post-thumbnail":{"file":"IMG-20250518-WA0030-604x270.jpg","width":604,"height":270,"filesize":32149,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030-604x270.jpg"},"full":{"file":"IMG-20250518-WA0030.jpg","width":946,"height":1313,"mime_type":"image\/jpeg","source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030.jpg"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"1","keywords":[]}},"post":null,"source_url":"https:\/\/www.tierhilfeweidenberg.de\/wp-content\/uploads\/2025\/05\/IMG-20250518-WA0030.jpg","filename":"IMG-20250518-WA0030.jpg","filesize":323953,"_links":{"self":[{"href":"https:\/\/www.tierhilfeweidenberg.de\/en\/wp-json\/wp\/v2\/media\/4555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tierhilfeweidenberg.de\/en\/wp-json\/wp\/v2\/media"}],"about":[{"href":"https:\/\/www.tierhilfeweidenberg.de\/en\/wp-json\/wp\/v2\/types\/attachment"}],"author":[{"embeddable":true,"href":"https:\/\/www.tierhilfeweidenberg.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tierhilfeweidenberg.de\/en\/wp-json\/wp\/v2\/comments?post=4555"}]}}