27 lines · 907 B
Raw Download
1
<?php
2
// download_report.php
3
require_once 'functions.php';
4
require_once 'parse_colors.php';
5
6
function generateColorReport($colors, $contrast_method = 'wcag') {
7
	if (!empty($colors)) {
8
		$result = processColorForm($colors);
9
		$parsed_colors = $result['parsed_colors'];
10
		$excess_colors = $result['excess_colors'];
11
		$invalid_colors = $result['invalid_colors'];
12
		$duplicate_colors = $result['duplicate_colors'];
13
		$semantic_duplicates = $result['semantic_duplicates'];
14
		// log a usage for our stats.txt
15
		date_default_timezone_set('America/Chicago');
16
		$datetime = date('Y-m-d h:i:s A');
17
		$file = 'stats.txt';
18
		$value = count($parsed_colors)." colors, ".$contrast_method." method";
19
		// Create the log entry
20
		$logEntry = $datetime . ", " . $value . ", download" . PHP_EOL;
21
		file_put_contents($file, $logEntry, FILE_APPEND);
22
		ob_start();
23
		include 'report_template.php';
24
		return ob_get_clean();
25
	}
26
}
27
?>