Created At: 2026-06-14T16:14:55Z
Completed At: 2026-06-14T16:14:55Z
File Path: `file:///C:/Users/HP/.gemini/antigravity-ide/brain/d31b1fe2-ad06-4c7a-9ab1-c82bd4c8dd20/scratch/restore_stripes_regex.php`
Total Lines: 558
Total Bytes: 31598
Showing lines 1 to 558
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
1: <?php
2: $origPath = 'c:/Users/HP/Downloads/climate-system/temp_extract/climate-system/index.php';
3: $destPath = 'c:/Users/HP/Downloads/climate-system/climate-system/index.php';
4: 
5: if (!file_exists($origPath)) {
6:     die("Original index.php not found at $origPath\n");
7: }
8: 
9: $content = file_get_contents($origPath);
10: 
11: // Define diff blocks (Target => Replacement)
12: $replacements = [
13:     // 1. Baseline anomaly check
14:     'if (stripos($variable_sanitized, \'precip\') !== false || stripos($variable_sanitized, \'hujan\') !== false) {
15:         $base = 2300; // default baseline (curah hujan)' 
16:     => 
17:     'if (stripos($variable_sanitized, \'anomaly\') !== false || stripos($variable_sanitized, \'anomali\') !== false) {
18:         $base = 0.5; // default baseline (anomali suhu)
19:     } else if (stripos($variable_sanitized, \'precip\') !== false || stripos($variable_sanitized, \'hujan\') !== false) {
20:         $base = 2300; // default baseline (curah hujan)',
21: 
22:     // 2. cols_to_add DB schema migration columns
23:     '\'graph_ssp3_slope\' => \'REAL DEFAULT NULL\',
24:         \'graph_ssp5_slope\' => \'REAL DEFAULT NULL\',
25:         \'csv_data\' => \'TEXT DEFAULT NULL\',
26:         \'image_climate_map_url_2\' => "TEXT DEFAULT \'\'"
27:     ];'
28:     =>
29:     '\'graph_ssp3_slope\' => \'REAL DEFAULT NULL\',
30:         \'graph_ssp5_slope\' => \'REAL DEFAULT NULL\',
31:         \'csv_data\' => \'TEXT DEFAULT NULL\',
32:         \'image_climate_map_url_2\' => "TEXT DEFAULT 
<truncated 30770 bytes>
();
510: 
511:         if (result.success) {
512:           alert(\'Data Climate Stripe berhasil disimpan ke database SQLite!\');
513:           await loadFilters();
514:         } else {
515:           alert(\'Gagal menyimpan: \' + (result.error || result.message));
516:         }
517:       } catch (err) {
518:         console.error(err);
519:         alert(\'Gagal mengirim data penyimpanan ke server.\');
520:       }
521:     }
522: 
523:     async function loadFutureGraphSettingsData() {',
524: 
525:     // 23. JS settings init stripe call on load
526:     '// Load initial settings data (which also triggers updateSettingsChartPreview)
527:       await loadHistoricalSettingsData();
528:       await loadFutureMapSettingsData();
529:       await loadFutureGraphSettingsData();'
530:     =>
531:     '// Load initial settings data (which also triggers updateSettingsChartPreview)
532:       await loadHistoricalSettingsData();
533:       await loadFutureMapSettingsData();
534:       await loadFutureStripeSettingsData();
535:       await loadFutureGraphSettingsData();',
536: ];
537: 
538: $successCount = 0;
539: foreach ($replacements as $target => $replacement) {
540:     // Normalise whitespace sequence for fuzzy matching
541:     $target_pattern = '/' . preg_replace('/\s+/', '\s+', preg_quote($target, '/')) . '/';
542:     
543:     $count = 0;
544:     $new_content = preg_replace($target_pattern, $replacement, $content, 1, $count);
545:     if ($count > 0 && $new_content !== null) {
546:         $content = $new_content;
547:         $successCount++;
548:     } else {
549:         echo "WARNING: target block not found using regex:\n" . substr($target, 0, 80) . "...\n\n";
550:     }
551: }
552: 
553: echo "Successfully applied $successCount / " . count($replacements) . " regex edits.\n";
554: 
555: // Write back to index.php
556: file_put_contents($destPath, $content);
557: echo "Written restored stripes content to $destPath\n";
558: 
The above content shows the entire, complete file contents of the requested file.
