HEX
Server: Apache/2
System: Linux vps.masterdigitaluev.com 4.18.0 #1 SMP Tue Jul 14 14:35:05 CEST 2026 x86_64
User: usuario3 (1035)
PHP: 8.3.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/usuario3/public_html/wp-content/plugins/pojo-accessibility/modules/scanner/classes/utils.php
<?php

namespace EA11y\Modules\Scanner\Classes;

use EA11y\Modules\Remediation\Database\Page_Entry;
use EA11y\Modules\Remediation\Database\Remediation_Entry;
use EA11y\Modules\Scanner\Database\Scan_Entry;
use Exception;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

class Utils {
	/**
	 * @throws Exception
	 */
	public static function create_tmp_file_from_png_base64( $base64_string ): string {
		// Check if the base64 string starts with 'data:image/png;base64,'
		if ( preg_match( '/^data:image\/png;base64,(.+)$/', $base64_string, $matches ) ) {
			$base64_data = $matches[1];
		} else {
			throw new Exception( 'Invalid base64 PNG format' );
		}

		// Decode the base64 data
		$image_data = base64_decode( $base64_data );

		if ( false === $image_data ) {
			throw new Exception( 'Failed to decode base64 PNG' );
		}

		// Save the image to a temporary file
		$tmp_path = tempnam( sys_get_temp_dir(), 'png_' ) . '.png';
		file_put_contents( $tmp_path, $image_data );

		return $tmp_path;
	}

	public static function get_scanner_stats(): array {
		$output = [
			'pages' => 0,
			'issues_opened' => 0,
			'issues_fixed' => 0,
		];

		$pages_scanned = Page_Entry::get_pages();

		foreach ( $pages_scanned as $page ) {
			$scans = Scan_Entry::get_scans( $page->url, 1 );
			$remediation_count = Remediation_Entry::get_page_remediations_count( $page->url );

			if ( count( $scans ) > 0 ) {
				$output['issues_opened'] += $scans[0]->summary['counts']['violation'] ?? 0;
				$output['issues_fixed'] += $remediation_count;
			}
		}

		$output['pages'] = count( $pages_scanned );

		return $output;
	}
}