";
echo "Rupee Symbol Fix Script
";
if ($dryRun) {
echo "DRY RUN MODE - No changes will be made. Add &apply=yes to URL to apply fixes.
";
} else {
echo "APPLYING FIXES
";
}
// The broken sequence: ₹ is what ₹ looks like when UTF-8 bytes are read as Latin1
// UTF-8 for ₹ (U+20B9) is: 0xE2 0x82 0xB9
// When read as Latin1: â (0xE2) ‚ (0x82) ¹ (0xB9) = ₹
$brokenRupee = "\xC3\xA2\xC2\x82\xC2\xB9"; // Double-encoded UTF-8
$brokenRupee2 = "₹"; // As it appears in source
$replacement = "₹"; // HTML entity for ₹ - works everywhere
// Files to check (relative to this script's directory)
$baseDir = __DIR__;
$files = [
'about.php',
'admin-support.php',
'articles.php',
'dashboard.php',
'doubts.php',
'index.php',
'points-manager.php',
'profiler.php',
'redemption.php',
'signup.php',
'terms.php',
'partners/data-sync.php',
'partners/members.php',
'partners/partner-config.php',
'partners/partner-dashboard.php',
'partners/redemptions.php',
];
$totalFixed = 0;
echo "";
echo "| File | Occurrences | Status |
";
foreach ($files as $relPath) {
$fullPath = $baseDir . '/' . $relPath;
if (!file_exists($fullPath)) {
echo "| $relPath | - | File not found (skip) |
";
continue;
}
$content = file_get_contents($fullPath);
// Count occurrences of both patterns
$count1 = substr_count($content, $brokenRupee);
$count2 = substr_count($content, $brokenRupee2);
$totalCount = max($count1, $count2); // They may overlap, take the higher count
// Also check for raw ₹ that might work but could break during file transfer
$rawRupee = "\xE2\x82\xB9"; // Actual UTF-8 bytes for ₹
$rawCount = substr_count($content, $rawRupee);
if ($totalCount === 0 && $rawCount === 0) {
echo "| $relPath | 0 | Clean |
";
continue;
}
if ($totalCount > 0) {
if (!$dryRun) {
// Replace both patterns
$newContent = str_replace($brokenRupee, $replacement, $content);
$newContent = str_replace($brokenRupee2, $replacement, $newContent);
// Also replace raw ₹ with entity for safety
$newContent = str_replace($rawRupee, $replacement, $newContent);
// Don't double-replace: if ₹ already exists, don't touch it
// (the replacements above won't create doubles since we're replacing different patterns)
file_put_contents($fullPath, $newContent);
echo "| $relPath | $totalCount broken | FIXED ✓ |
";
} else {
echo "| $relPath | $totalCount broken | Will fix |
";
}
$totalFixed += $totalCount;
} elseif ($rawCount > 0) {
if (!$dryRun) {
$newContent = str_replace($rawRupee, $replacement, $content);
file_put_contents($fullPath, $newContent);
echo "| $relPath | $rawCount raw ₹ | Converted to entity ✓ |
";
} else {
echo "| $relPath | $rawCount raw ₹ | Will convert to entity |
";
}
$totalFixed += $rawCount;
}
}
echo "
";
echo "Total replacements: $totalFixed
";
if ($dryRun) {
echo "Apply Fixes Now
";
} else {
echo "IMPORTANT: Delete this file now! rm fix-rupee.php
";
}
echo "