<commit_before><?php

include '../pokemonshowdown.com/config/servers.inc.php';

spl_autoload_register(function ($class) {
	require_once('lib/css-sanitizer/'.$class.'.php');
});

use Wikimedia\CSS\Parser\Parser;
use Wikimedia\CSS\Sanitizer\StylesheetSanitizer;

$server = @$_REQUEST['server'];
if ($server === 'showdown' || $server === 'smogtours') die();
if (empty($PokemonServers[$server])) {
	header('Content-Type: text/plain; charset=utf-8');
	die('server not found');
}

$invalidate = isset($_REQUEST['invalidate']);

if (!$invalidate) header('Content-Type: text/css'); // the CSS file should specify a charset

$serverdata =& $PokemonServers[$server];
$customcssuri = @$serverdata['customcss'];
if (empty($customcssuri)) {
	$protocol = ($serverdata['port'] === 443) ? 'https' : 'http';
	$customcssuri = $protocol . '://'.$serverdata['server'].':'.$serverdata['port'].'/custom.css';
}

// No need to sanitise $server because it should be safe already.
$cssfile = '../pokemonshowdown.com/config/customcss/' . $server . '.css';

$lastmodified = @filemtime($cssfile);
$timenow = time();
$expiration = ($lastmodified ? $lastmodified : $timenow) + 3600;
header('Expires: ' . gmdate('D, d M Y H:i:s T', $expiration));

// echo '/* ', $customcssuri, ' */';<commit_msg>Fix Linux/macOS support for CSS sanitizer<commit_after><?php

include '../pokemonshowdown.com/config/servers.inc.php';

spl_autoload_register(function ($class) {
	require_once('lib/css-sanitizer/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php');
});

use Wikimedia\CSS\Parser\Parser;

use Wikimedia\CSS\Sanitizer\StylesheetSanitizer;

$server = @$_REQUEST['server'];
if ($server === 'showdown' || $server === 'smogtours') die();
if (empty($PokemonServers[$server])) {
	header('Content-Type: text/plain; charset=utf-8');
	die('server not found');
}

$invalidate = isset($_REQUEST['invalidate']);

if (!$invalidate) header('Content-Type: text/css'); // the CSS file should specify a charset

$serverdata =& $PokemonServers[$server];
$customcssuri = @$serverdata['customcss'];
if (empty($customcssuri)) {
	$protocol = ($serverdata['port'] === 443) ? 'https' : 'http';
	$customcssuri = $protocol . '://'.$serverdata['server'].':'.$serverdata['port'].'/custom.css';
}

// No need to sanitise $server because it should be safe already.
$cssfile = '../pokemonshowdown.com/config/customcss/' . $server . '.css';

$lastmodified = @filemtime($cssfile);
$timenow = time();
$expiration = ($lastmodified ? $lastmodified : $timenow) + 3600;
header('Expires: ' . gmdate('D, d M Y H:i:s T', $expiration));

// echo '/* ', $customcssuri, ' */';
{'fraction_non_alphanumeric': 0.21354367064255483, 'fraction_numerical': 0.0061562139284340135, 'mean_word_length': 5.565656565656566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1400436', 'n_tokens_mistral': 911, 'n_tokens_neox': 903, 'n_words': 181}