Created At: 2026-06-14T13:53:43Z
Completed At: 2026-06-14T13:53:44Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4584
Total Bytes: 193825
Showing lines 350 to 385
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.
350:             $statistic = isset($_GET['statistic']) ? trim($_GET['statistic']) : 'Mean';
351:             $start_year = isset($_GET['start_year']) && $_GET['start_year'] !== '' ? intval($_GET['start_year']) : null;
352:             $end_year = isset($_GET['end_year']) && $_GET['end_year'] !== '' ? intval($_GET['end_year']) : null;
353: 
354:             if (empty($location) || empty($variable)) {
355:                 echo json_encode(['success' => false, 'error' => 'Parameter lokasi dan variabel tidak boleh kosong.']);
356:                 exit;
357:             }
358: 
359:             // Sanitasi input untuk mencegah Directory Traversal
360:             $location_sanitized = str_replace(array('..', '/', '\\'), '', $location);
361:             $variable_sanitized = str_replace(array('..', '/', '\\'), '', $variable);
362: 
363:             // Auto-generate sample CSV jika belum ada demi pengalaman tanpa hambatan
364:             ensure_sample_csv_exists_ipcc($location_sanitized, $variable_sanitized);
365: 
366:             // Tentukan file utama berdasarkan filter Statistik
367:             $stat_map = [
368:                 'mean' => 'areal_averaged_ensmean.csv',
369:                 'median' => 'areal_averaged_ensmedian.csv',
370:                 'max' => 'areal_averaged_ensmax.csv',
371:                 'min' => 'areal_averaged_ensmin.csv',
372:                 'original' => 'areal_averaged.csv'
373:             ];
374:             $stat_lower = strtolower($statistic);
375:             $main_filename = isset($stat_map[$stat_lower]) ? $stat_map[$stat_lower] : 'areal_averaged_ensmean.csv';
376: 
377:             $variable_folder = $variable_sanitized;
378:             if ($variable_sanitized === 'Suhu Udara Minimum' || stripos($variable_sanitized, 'minimum') !== false) {
379:                 $variable_folder = 'Temperature Anomaly';
380:             }
381:             $dir = __DIR__ . "/data/{$location_sanitized}/{$variable_folder}";
382: 
383:             // Copy file ensmean jika main file kustom belum ada untuk mencegah error
384:             if (!file_exists("{$dir}/{$main_filename}") && file_exists("{$dir}/areal_averaged_ensmean.csv")) {
385:                 copy("{$dir}/areal_averaged_ensmean.csv", "{$dir}/{$main_filename}");
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.
