Created At: 2026-06-14T16:16:11Z
Completed At: 2026-06-14T16:16:11Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 3856
Total Bytes: 159351
Showing lines 101 to 200
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.
101:                     $ssp370 = $base - ($idx * 1.6) + sin($y * 1.5) * 140;
102:                     $ssp585 = $base + ($idx * 4.2) + cos($y * 2.0) * 180;
103:                 } else {
104:                     $ssp126 = $base + ($idx * 0.006) + sin($y) * 0.15;
105:                     $ssp245 = $base + ($idx * 0.016) + cos($y) * 0.2;
106:                     $ssp370 = $base + ($idx * 0.036) + sin($y * 1.5) * 0.25;
107:                     $ssp585 = $base + ($idx * 0.052) + cos($y * 2.0) * 0.3;
108:                 }
109:                 fputcsv($handle, [$y, round($ssp126, 2), round($ssp245, 2), round($ssp370, 2), round($ssp585, 2)]);
110:             }
111:             fclose($handle);
112:         }
113:     }
114: 
115:     // 3. areal_averaged_ensmin.csv (2021 - 2100)
116:     $min_path = "{$dir}/areal_averaged_ensmin.csv";
117:     if (!file_exists($min_path)) {
118:         $handle = fopen($min_path, "w");
119:         if ($handle !== FALSE) {
120:             fputcsv($handle, ['year', 'ssp126', 'ssp245', 'ssp370', 'ssp585']);
121:             for ($y = 2021; $y <= 2100; $y++) {
122:                 $idx = $y - 2021;
123:                 $spread = ($base > 1000) ? (200 + $idx * 3) : (0.25 + $idx * 0.005);
124:                 
125:                 if ($base > 1000) {
126:                     $ssp126 = ($base + ($idx * 0.4) + sin($y) * 90) - $spread;
127:                     $ssp245 = ($base + ($idx * 1.2) + cos($y) * 110) - $spread;
128:                     $ssp370 = ($base - ($idx * 1.6) + sin($y * 1.5) * 140) - $spread;
129:                     $ssp585 = 
<truncated 1730 bytes>
         $ssp245 = ($base + ($idx * 0.016) + cos($y) * 0.2) + $spread;
160:                     $ssp370 = ($base + ($idx * 0.036) + sin($y * 1.5) * 0.25) + $spread;
161:                     $ssp585 = ($base + ($idx * 0.052) + cos($y * 2.0) * 0.3) + $spread;
162:                 }
163:                 fputcsv($handle, [$y, round($ssp126, 2), round($ssp245, 2), round($ssp370, 2), round($ssp585, 2)]);
164:             }
165:             fclose($handle);
166:         }
167:     }
168: }
169: 
170: $db_file = __DIR__ . '/climate.db';
171: $db_exists = file_exists($db_file);
172: 
173: try {
174:     // Hubungkan ke SQLite Database
175:     $db = new PDO("sqlite:" . $db_file);
176:     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
177:     $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
178: 
179:     // Self-migrating database schema updates for dynamic graph parameters
180:     $cols_to_add = [
181:         'graph_base_value' => 'REAL DEFAULT NULL',
182:         'graph_uncertainty' => 'REAL DEFAULT NULL',
183:         'graph_ssp1_slope' => 'REAL DEFAULT NULL',
184:         'graph_ssp2_slope' => 'REAL DEFAULT NULL',
185:         'graph_ssp3_slope' => 'REAL DEFAULT NULL',
186:         'graph_ssp5_slope' => 'REAL DEFAULT NULL',
187:         'csv_data' => 'TEXT DEFAULT NULL',
188:         'image_climate_map_url_2' => "TEXT DEFAULT ''"
189:     ];
190:     foreach ($cols_to_add as $col_name => $col_def) {
191:         try {
192:             $db->exec("ALTER TABLE future_climate ADD COLUMN {$col_name} {$col_def}");
193:         } catch (PDOException $ex) {
194:             // Kolom sudah ada, abaikan saja
195:         }
196:     }
197: } catch (PDOException $e) {
198:     header('Content-Type: application/json');
199:     echo json_encode(['error' => 'Gagal terhubung ke database server.']);
200:     exit;
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
