session_start(); //uncomment to display errors, comment next line which suppresses error notices // ini_set('display_errors', 1); // ini_set('display_startup_errors', 1); //error_reporting(E_ALL); error_reporting(E_ERROR ); //check for district... using strlen because of vulneriability reported by MNIT $dist = strtoupper($_GET['district'] ?? '01A'); if (!preg_match('/^(0[1-9]|[1-5][0-9]|6[0-7])[AB]$/', $dist)) { http_response_code(400); exit('Invalid district.'); } //next districts $distval = intval($dist); if ($distval < 10 && strpos($dist, 'A') !== false ) { $ndist = "0" . $distval . "B"; } elseif ($distval < 9 && strpos($dist, 'B') !== false ) { $ndist1 = $distval + 1; $ndist = "0" . $ndist1 . "A"; } elseif ($distval > 8 && $distval <= 67 && strpos($dist, 'A') !== false ) $ndist = $distval . "B"; elseif ($distval > 8 && $distval <= 66 && strpos($dist, 'B') !== false ) { $ndist1 = $distval + 1; $ndist = $ndist1 . "A"; } else $ndist = "01A"; //previous districts if ($distval > 1 && $distval <= 10 && strpos($dist, 'A') !== false) { $pdist1 = $distval - 1; $pdist = "0" . $pdist1 . "B"; } elseif ($distval >= 1 && $distval < 10 && strpos($dist, 'B') !== false) $pdist = "0" . $distval . "A"; elseif ($distval > 9 && $distval <=67 && strpos($dist, 'A') !== false) { $pdist1 = $distval - 1; $pdist = $pdist1 . "B"; } elseif ($distval > 9 && $distval <=67 && strpos($dist, 'B') !== false) $pdist = $distval . "A"; else $pdist = "67B"; $allowedSections = ['dp02', 'dp03', 'dp04', 'dp05']; $sect = strtolower($_GET['section'] ?? 'dp05'); if (!in_array($sect, $allowedSections, true)) { http_response_code(400); exit('Invalid section.'); } //set active tab and title if ($sect == 'dp05') { $title = "Demographic"; $dp05 = 'nav-link active text-joint font-weight-bold'; }else { $dp05 = 'nav-link'; } if ($sect == 'dp02') { $title = "Social"; $dp02 = 'nav-link active text-joint font-weight-bold'; }else { $dp02 = 'nav-link'; } if ($sect == 'dp03') { $title = "Economic"; $dp03 = 'nav-link active text-joint font-weight-bold'; }else { $dp03 = 'nav-link'; } if ($sect == 'dp04') { $title = "Housing"; $dp04 = 'nav-link active text-joint font-weight-bold'; }else { $dp04 = 'nav-link'; } include_once('/home/web/gis/config/config.php'); $pageTitle = 'MN House Profiles'; $announcement = file_get_contents('/web/config/announcement.php'); include_once($header); print "
"; //title print "| Subject | District | Percent |
|---|---|---|
| $line1 | $num2 | $row3[$i] |
| $line1 | $num2 | $row3[$i] |