data = $data; $this->debug_logger = $debug_logger; $this->model = $debug_model; } protected function get_nonce_name() { return self::ACTION_NAME; } public function handle() { if ( ! $this->validate() ) { echo __( 'Unauthorized', 'gravitysmtp' ); die(); } $lines = $this->debug_logger->get_log_items(); echo '
';
		foreach ( $lines as $index => $item ) {
			printf( "%s %s - %s -->    %s", str_pad( '[' . $item->id() . ']', 8, ' ' ), $item->timestamp(), strtoupper( str_pad( $item->priority(), 7, ' ' ) ), esc_html( $item->line() ) );
			if ( $index < count( $lines ) - 1 ) {
				echo '

';
			}
		}
		echo '
'; die(); } protected function validate() { // Ensure logging is enabled. $enabled = $this->data->get_plugin_setting( Tools_Config::SETTING_DEBUG_LOG_ENABLED, false ); if ( ! $enabled ) { return false; } if ( is_user_logged_in() ) { return current_user_can( Roles::VIEW_DEBUG_LOG ); } // Get the passed verficiation key; bail if empty. $key = filter_input( INPUT_GET, self::PARAM_LOG_KEY ); if ( empty( $key ) ) { return false; } // Get the stored verification key; if it is empty or does not match the provided key, bail. $key = htmlspecialchars( $key ); $check = get_option( self::OPTION_VERIFICATION_KEY ); if ( empty( $check ) || $check !== $key ) { return false; } return true; } }