Updated Doormile website

This commit is contained in:
R-Bharathraj
2026-05-15 11:21:50 +05:30
commit 4f39822cb7
287 changed files with 218662 additions and 0 deletions

91
non-used/fix_encoding.php Normal file
View File

@@ -0,0 +1,91 @@
<?php
/**
* Fix encoding issues and broken symbols in the project.
*/
$directory = __DIR__;
$extensions = ['php', 'html', 'css', 'js'];
// Define replacements for various corrupted sequences
$replacements = [
// Corrupted Trademark
'â„¢' => '&trade;',
'MileTruth<superscript>&trade;</superscript>' => 'MileTruth&trade;',
'MileTruth<superscript>™</superscript>' => 'MileTruth&trade;',
'MileTruth™' => 'MileTruth&trade;',
// Corrupted quotes and dashes (UTF-8 bytes misinterpreted as ISO-8859-1 and then saved as UTF-8)
'–' => '&ndash;',
'—' => '&mdash;',
'’' => '&rsquo;',
'“' => '&ldquo;',
'â€' => '&rdquo;',
'…' => '&hellip;',
'•' => '&bull;',
// Corrupted spaces and symbols
'©' => '&copy;',
' ' => ' ', // Often  + nbsp
'Â' => '', // Lone  artifact
'ðŸ' => '', // Broken emoji
// Fix existing trade entities if needed
'<sup>&trade;</sup>' => '&trade;',
'<superscript>&trade;</superscript>' => '&trade;',
'<superscript>™</superscript>' => '&trade;',
];
/**
* Recursively find all files with specific extensions.
*
* @param string $dir
* @param array $extensions
* @return array
*/
function get_all_files(string $dir, array $extensions): array {
$files = [];
$items = scandir($dir);
foreach ($items as $item) {
if ($item == '.' || $item == '..' || $item == '.git' || $item == 'non-used' || $item == 'fix_encoding.php') continue;
$path = $dir . DIRECTORY_SEPARATOR . $item;
if (is_dir($path)) {
$files = array_merge($files, get_all_files($path, $extensions));
} else {
$ext = pathinfo($path, PATHINFO_EXTENSION);
if (in_array($ext, $extensions)) {
$files[] = $path;
}
}
}
return $files;
}
$files = get_all_files($directory, $extensions);
echo "Processing " . count($files) . " files...\n";
foreach ($files as $file) {
$content = file_get_contents($file);
if ($content === false) continue;
$original_content = $content;
// Apply replacements multiple times to handle nested issues
$changed = true;
while ($changed) {
$old_content = $content;
foreach ($replacements as $search => $replace) {
$content = str_replace($search, $replace, $content);
}
if ($old_content === $content) {
$changed = false;
}
}
if ($content !== $original_content) {
file_put_contents($file, $content);
echo "Fixed: $file\n";
}
}
echo "Done.\n";