mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-29 08:06:58 +09:00
* cleanup: remove unreachable defensive error logs in aggregate graph item validation * fix: replace strtolower/strtoupper with locale-independent wrappers PHP 8.5 deprecates locale-sensitive strtolower() and strtoupper(). Add cacti_strtolower() and cacti_strtoupper() wrappers that use mb_strtolower/mb_strtoupper with explicit UTF-8 encoding, then replace all 185 call sites across 65 files. Existing mb_strtolower() calls (email normalization) are left as-is since they already specify encoding explicitly. Includes 18 Pest tests covering ASCII, UTF-8, protocol names, config values, hex strings, NaN detection, and file extension patterns. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: correct docblock references and month_shift() strpos check Fix docblocks to reference strtolower()/strtoupper() (the deprecated PHP builtins) instead of the wrapper names. Fix month_shift() to use strpos() !== false instead of > 0 so 'month' at position 0 is matched. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * chore: drop unrelated lib/api_aggregate changes Keep PR scope focused on the issue for this branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: TheWitness <thewitness@cacti.net>
78 lines
2.8 KiB
PHP
78 lines
2.8 KiB
PHP
<?php
|
|
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2026 The Cacti Group |
|
|
| |
|
|
| This program is free software; you can redistribute it and/or |
|
|
| modify it under the terms of the GNU General Public License |
|
|
| as published by the Free Software Foundation; either version 2 |
|
|
| of the License, or (at your option) any later version. |
|
|
| |
|
|
| This program is distributed in the hope that it will be useful, |
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
| GNU General Public License for more details. |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDTool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
| This code is designed, written, and maintained by the Cacti Group. See |
|
|
| about.php and/or the AUTHORS file for specific developer information. |
|
|
+-------------------------------------------------------------------------+
|
|
| http://www.cacti.net/ |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
function update_hash(string $file) : void {
|
|
}
|
|
|
|
function file_search(string $folder, array $pattern_array) : array {
|
|
$return = [];
|
|
$iti = new RecursiveDirectoryIterator($folder);
|
|
|
|
foreach (new RecursiveIteratorIterator($iti) as $file) {
|
|
$fileParts = explode('.', $file);
|
|
|
|
if (in_array(cacti_strtolower(array_pop($fileParts)), $pattern_array, true)) {
|
|
$return[] = $file;
|
|
}
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
function file_hash(array $match) : string {
|
|
global $cssFile;
|
|
$md5File = dirname($cssFile) . '/' . $match[2];
|
|
$md5Real = realpath($md5File);
|
|
$md5Hash = md5_file($md5File);
|
|
$result = $match[1] . $match[2] . '?' . $md5Hash . $match[4];
|
|
|
|
return $result;
|
|
}
|
|
|
|
function file_update(string $cssFile) : void {
|
|
$fileContents = file($cssFile);
|
|
$fileUpdated = preg_replace_callback_array(
|
|
[
|
|
'/(@import url\(\')([^?]*)(\?.*)*(\'\))/' => 'file_hash',
|
|
'/(@import url\(")([^?]*)(\?.*)*("\))/' => 'file_hash',
|
|
], $fileContents
|
|
);
|
|
|
|
if ($fileContents != $fileUpdated) {
|
|
print 'file_update(' . $cssFile . ")\n";
|
|
file_put_contents($cssFile, $fileUpdated);
|
|
}
|
|
}
|
|
|
|
global $cssFile;
|
|
$cssFiles = file_search(__DIR__ . '/css', ['css']);
|
|
$cssFiles[] = __DIR__ . '/main.css';
|
|
$cssFiles[] = __DIR__ . '/billboard.midwinter.css';
|
|
|
|
foreach ($cssFiles as $cssFile) {
|
|
file_update($cssFile);
|
|
}
|
|
|
|
print PHP_EOL;
|