Created At: 2026-06-14T16:14:54Z
Completed At: 2026-06-14T16:14:54Z
File Path: `file:///C:/Users/HP/.gemini/antigravity-ide/brain/d31b1fe2-ad06-4c7a-9ab1-c82bd4c8dd20/scratch/restore_stripes.php`
Total Lines: 562
Total Bytes: 31602
Showing lines 1 to 562
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 30788 bytes>
         alert(\'Data Climate Stripe berhasil disimpan ke database SQLite!\');
516:           await loadFilters();
517:         } else {
518:           alert(\'Gagal menyimpan: \' + (result.error || result.message));
519:         }
520:       } catch (err) {
521:         console.error(err);
522:         alert(\'Gagal mengirim data penyimpanan ke server.\');
523:       }
524:     }
525: 
526:     async function loadFutureGraphSettingsData() {',
527: 
528:     // 23. JS settings init stripe call on load
529:     '      // Load initial settings data (which also triggers updateSettingsChartPreview)
530:       await loadHistoricalSettingsData();
531:       await loadFutureMapSettingsData();
532:       await loadFutureGraphSettingsData();'
533:     =>
534:     '      // Load initial settings data (which also triggers updateSettingsChartPreview)
535:       await loadHistoricalSettingsData();
536:       await loadFutureMapSettingsData();
537:       await loadFutureStripeSettingsData();
538:       await loadFutureGraphSettingsData();',
539: ];
540: 
541: $successCount = 0;
542: foreach ($replacements as $target => $replacement) {
543:     // Normalize target line endings
544:     $target_norm = str_replace("\r\n", "\n", $target);
545:     $content_norm = str_replace("\r\n", "\n", $content);
546:     
547:     $pos = strpos($content_norm, $target_norm);
548:     if ($pos !== false) {
549:         // Replace target with replacement in normalized form to avoid mismatch
550:         $content = str_replace($target_norm, $replacement, $content_norm);
551:         $successCount++;
552:     } else {
553:         echo "WARNING: target block not found:\n" . substr($target, 0, 100) . "...\n\n";
554:     }
555: }
556: 
557: echo "Successfully applied $successCount / " . count($replacements) . " edits.\n";
558: 
559: // Write back to index.php
560: file_put_contents($destPath, $content);
561: echo "Written restored stripes content to $destPath\n";
562: 
The above content shows the entire, complete file contents of the requested file.
