From 55b64b30cd892fc46b09cdafbf29d58b78ff4245 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Mon, 20 Jul 2015 21:31:29 -0400 Subject: [PATCH] Improve custom CSS support The main server is now hardcoded not to support custom CSS, which should save a decent amount of server resource use. In addition, the request for custom CSS now comes with a user agent, to make it clearer what it's doing. --- customcss.php | 10 +++++++++- js/client.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/customcss.php b/customcss.php index 54322c366..af98cf372 100644 --- a/customcss.php +++ b/customcss.php @@ -3,6 +3,7 @@ include '../pokemonshowdown.com/config/servers.inc.php'; $server = @$_REQUEST['server']; +if ($server === 'showdown') die(); if (empty($PokemonServers[$server])) { header('Content-Type: text/plain; charset=utf-8'); die('server not found'); @@ -38,7 +39,14 @@ if (!$invalidate && $lastmodified && (($timenow - $lastmodified) < 3600)) { $curl = curl_init($customcssuri); if ($lastmodified && !$invalidate) { curl_setopt($curl, CURLOPT_HTTPHEADER, array( - 'If-Modified-Since: ' . gmdate('D, d M Y H:i:s T', $lastmodified) + 'If-Modified-Since: ' . gmdate('D, d M Y H:i:s T', $lastmodified), + 'User-Agent: PSCustomCSS/0.1 (server=' . $server . ($invalidate ? '; invalidate=1' : '') . ')', + // 'X-Forwarded-For: ' . @$_SERVER['HTTP_X_FORWARDED_FOR'], + )); +} else { + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'User-Agent: PSCustomCSS/0.1 (server=' . $server . ($invalidate ? '; invalidate=1' : '') . ')', + // 'X-Forwarded-For: ' . @$_SERVER['HTTP_X_FORWARDED_FOR'], )); } curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); diff --git a/js/client.js b/js/client.js index 9dff9a4ea..e7c2db176 100644 --- a/js/client.js +++ b/js/client.js @@ -682,7 +682,7 @@ // server config information Config.server = data.server; // Config.server.afd = true; - if (Config.server.registered) { + if (Config.server.registered && Config.server.id !== 'showdown') { var $link = $('');