mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Merge pull request #6017 from 3D-I/ticket/16543
[ticket/16543] Update query-string in stylesheet.css to hashes
This commit is contained in:
commit
55c4fd644c
2 changed files with 66 additions and 12 deletions
54
build/update_stylesheet_querystrings.php
Normal file
54
build/update_stylesheet_querystrings.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (php_sapi_name() !== 'cli')
|
||||||
|
{
|
||||||
|
die("This program must be run from the command line.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version_compare(PHP_VERSION, '7.1.3', '<'))
|
||||||
|
{
|
||||||
|
die('update_stylesheet_querystrings.php requires at least PHP 7.1.3');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage: "$ php build/update_stylesheet_querystrings.php"
|
||||||
|
$targets = [dirname(dirname(__FILE__)) . '/phpBB/styles/prosilver/theme/stylesheet.css'];
|
||||||
|
|
||||||
|
array_map('patch_glob', $targets);
|
||||||
|
|
||||||
|
function patch_glob($glob): void
|
||||||
|
{
|
||||||
|
array_map('patch_file', glob($glob));
|
||||||
|
}
|
||||||
|
|
||||||
|
function patch_file(string $filepath): void
|
||||||
|
{
|
||||||
|
$file = file_get_contents($filepath);
|
||||||
|
$old = $file;
|
||||||
|
$new = preg_replace_callback(
|
||||||
|
'(^@import\\s+url\\([\'"](?<basename>\\w++\\.css)\\?\\K(?:hash|v)=[^\'"]++)m',
|
||||||
|
function ($match) use ($filepath)
|
||||||
|
{
|
||||||
|
$path = dirname($filepath) . DIRECTORY_SEPARATOR . $match['basename'];
|
||||||
|
$hash = sprintf('%08x', crc32(file_get_contents($path)));
|
||||||
|
|
||||||
|
return 'hash=' . $hash;
|
||||||
|
},
|
||||||
|
$old
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($new !== $old)
|
||||||
|
{
|
||||||
|
file_put_contents($filepath, $new);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,15 +7,15 @@
|
||||||
--------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@import url("normalize.css?v=3.3");
|
@import url("normalize.css?hash=48eb3f89");
|
||||||
@import url("base.css?v=3.3");
|
@import url("base.css?hash=3a7fafb1");
|
||||||
@import url("utilities.css?v=3.3");
|
@import url("utilities.css?hash=1034bac8");
|
||||||
@import url("common.css?v=3.3");
|
@import url("common.css?hash=009a715d");
|
||||||
@import url("links.css?v=3.3");
|
@import url("links.css?hash=da040ebb");
|
||||||
@import url("content.css?v=3.3");
|
@import url("content.css?hash=d7d65e66");
|
||||||
@import url("buttons.css?v=3.3");
|
@import url("buttons.css?hash=15c14833");
|
||||||
@import url("cp.css?v=3.3");
|
@import url("cp.css?hash=5cc9ac0c");
|
||||||
@import url("forms.css?v=3.3");
|
@import url("forms.css?hash=18ee8211");
|
||||||
@import url("icons.css?v=3.3");
|
@import url("icons.css?hash=ed93c566");
|
||||||
@import url("colours.css?v=3.3");
|
@import url("colours.css?hash=3b03ccfa");
|
||||||
@import url("responsive.css?v=3.3");
|
@import url("responsive.css?hash=438ff202");
|
||||||
|
|
Loading…
Add table
Reference in a new issue