File: /home/awaldron/_accomods/_apibak/schoolLookup.php
<?php
include('cors.php');
function stripAttributes( $html, $emptyText='' ) {
$find = [' ', '’', '“', '”', 'o:p', '–'];
$repl = ['', "'", '"', '"', 'p'. '-'];
$html = preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/si",'<$1$2>', $html);
$html = str_ireplace($find, $repl, $html);
$html = strip_tags($html, ['p','a','br','ul','li','ol','sub','sup','strike','i','b','strong']);
return (empty($html) ? $emptyText : $html);
}
cors();
$codes = file('schoolCodes.txt');
$codeIn = $_GET['sc'];
$returnCode = [];
$codeFound = false;
foreach($codes as $line) {
$info = explode('||', $line);
$code1 = preg_replace('/[^a-zA-Z0-9]/','', strtolower($info[1]));
$code2 = preg_replace('/[^a-zA-Z0-9]/','', strtolower($codeIn));
if ($code1 === $code2) {
$codeFound = true;
$returnCode = $info;
}
}
if ($codeFound) {
$data = ['success'=>true, 'schoolName'=>$returnCode[0], 'schoolCode'=>$returnCode[1]];
}
else {
$data = ['success'=>false, 'data'=>null];
}
header('Content-Type: application/json');
echo json_encode($data);