$person = lookup_username($_REQUEST["username"]); if ($appError == 0) { $person = html_escape_person($person); require "$page->branch/detail.html"; } else { $errorMessage = $person; require "$page->branch/index.html"; } } elseif ($search_terms) { //search mit ldap directory $people = mit_search($search_terms); if ($appError != 1) { $people = html_escape_people($people); $total = count($people); if ($total == 0) { $failed_search = True; require "$page->branch/index.html"; } elseif ($total == 1) { $person = $people[0]; require "$page->branch/detail.html"; } else
$search_term = $_REQUEST['q']; $key = strtolower($_REQUEST['key']); if ($search_term == '') { echo "Error: No Query"; } else { if ($key == '') { echo "Error: No Key"; } else { if (strlen($search_term) > 50) { echo "Error: Too much data"; } else { if (strlen($key) > 32) { echo "Error: Too much data"; } else { if ($key == md5($search_term . $secret_word)) { $raw_people = mit_search($_REQUEST['q']); $people = array(); foreach ($raw_people as $raw_person) { $person = array(); foreach ($raw_person as $attribute => $value) { if ($value) { $person[$attribute] = $value; } } $people[] = $person; } $total = count($people); $result = array('resultSet' => array('totalResultsAvailable' => $total, 'totalResultsReturned' => $total, 'firstResultPosition' => 1, 'result' => $people)); $json = new Services_JSON(); echo $json->encodeUnsafe($result); } else {