Upload perdana untuk deploy
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Script to fix broken emoji encoding in app.js
|
||||
* Replaces mojibake characters with HTML entity codes
|
||||
*/
|
||||
|
||||
$file = __DIR__ . '/assets/js/app.js';
|
||||
$content = file_get_contents($file);
|
||||
|
||||
if ($content === false) {
|
||||
die("ERROR: Cannot read file: $file\n");
|
||||
}
|
||||
|
||||
$original_length = strlen($content);
|
||||
|
||||
// Map of broken mojibake -> correct HTML entity replacement
|
||||
$replacements = [
|
||||
// Broken trash can emoji (ðŸ—') -> HTML entity for 🗑
|
||||
"\xC3\xB0\xC5\xB8\xE2\x80\x97\xE2\x80\x99" => "🗑",
|
||||
|
||||
// Broken mosque emoji (🕌) -> HTML entity for 🏢
|
||||
"\xC3\xB0\xC5\xB8\xE2\x80\xA2\xC5\x92" => "🏢",
|
||||
|
||||
// Broken person emoji (ðŸ'¤) -> HTML entity for 👤
|
||||
"\xC3\xB0\xC5\xB8\xE2\x80\x98\xC2\xA4" => "👤",
|
||||
|
||||
// Broken satellite emoji (ðŸ"¡) -> HTML entity for 📡
|
||||
"\xC3\xB0\xC5\xB8\xE2\x80\x9C\xC2\xA1" => "📡",
|
||||
|
||||
// Broken pencil (âœ) -> HTML entity for ✏️
|
||||
"\xC3\xA2\xC5\x93" => "✏️",
|
||||
|
||||
// Broken square emoji (â¬) -> HTML entity for 📐
|
||||
"\xC3\xA2\xC2\xAC" => "📐",
|
||||
|
||||
// Broken m² (m²) -> correct m²
|
||||
"m\xC3\x82\xC2\xB2" => "m²",
|
||||
|
||||
// Broken info icon (ⓘ)
|
||||
"\xE2\x93\x98" => "ℹ",
|
||||
|
||||
// Broken warning icon (âš )
|
||||
"\xC3\xA2\xC5\xA1\xC2\xA0" => "⚠",
|
||||
|
||||
// Broken bullet (•)
|
||||
"\xC3\xA2\xE2\x80\x9A\xC2\xAC" => "•",
|
||||
];
|
||||
|
||||
$count = 0;
|
||||
foreach ($replacements as $broken => $fixed) {
|
||||
$occurrences = substr_count($content, $broken);
|
||||
if ($occurrences > 0) {
|
||||
$content = str_replace($broken, $fixed, $content);
|
||||
echo "Fixed: '$fixed' ($occurrences occurrences)\n";
|
||||
$count += $occurrences;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count === 0) {
|
||||
echo "No broken emoji patterns found. Trying alternative byte patterns...\n";
|
||||
|
||||
// Try reading the file as raw bytes and searching for patterns
|
||||
$hex = bin2hex($content);
|
||||
|
||||
// Let's search for common patterns around "Hapus" text
|
||||
$hapus_pos = strpos($content, 'Hapus');
|
||||
if ($hapus_pos !== false) {
|
||||
// Look at the bytes right before "Hapus" to see what the broken emoji looks like
|
||||
$before = substr($content, max(0, $hapus_pos - 20), 20);
|
||||
echo "Bytes before first 'Hapus': " . bin2hex($before) . "\n";
|
||||
echo "Chars before first 'Hapus': " . $before . "\n";
|
||||
}
|
||||
|
||||
// Search for "Edit" button text
|
||||
$edit_pos = strpos($content, 'Edit</button>');
|
||||
if ($edit_pos !== false) {
|
||||
$before = substr($content, max(0, $edit_pos - 10), 10);
|
||||
echo "Bytes before 'Edit': " . bin2hex($before) . "\n";
|
||||
}
|
||||
|
||||
// Search for mosque pattern near "item.nama"
|
||||
$fp_title = strpos($content, '${item.nama}');
|
||||
if ($fp_title !== false) {
|
||||
$before = substr($content, max(0, $fp_title - 15), 15);
|
||||
echo "Bytes before '\${item.nama}': " . bin2hex($before) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($count > 0) {
|
||||
// Backup
|
||||
copy($file, $file . '.bak');
|
||||
|
||||
// Write fixed content
|
||||
file_put_contents($file, $content);
|
||||
echo "\nTotal: $count emoji fixes applied.\n";
|
||||
echo "Backup saved as: app.js.bak\n";
|
||||
} else {
|
||||
echo "\nNo fixes applied.\n";
|
||||
}
|
||||
Reference in New Issue
Block a user