Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("../include/database.php");
- $webQuery = $_GET['query'];
- if($webQuery != null)
- {
- global $database, $session;
- if($webQuery == "news")
- {
- $result = $database->getNews();
- $json = "";
- echo "{ \"news\": [";
- while($row = mysql_fetch_array($result))
- {
- $json .= "{";
- $json .= "\"date\": \"".$row[0]."\",";
- $json .= "\"title\": \"".$row[1]."\",";
- $json .="\"content\": \"".$row[2]."\",";
- $json .="\"username\": \"".$row[3]."\",";
- $json .="\"email\": \"".$row[4]."\"";
- $json .="},";
- }
- $json = substr_replace($json,"",-1);
- echo $json;
- echo "]}";
- }
- else if($webQuery == "adduser")
- {
- $username = $_GET['username'];
- $password = $_GET['password'];
- $email = $_GET['email'];
- $contactemail = $_GET['contactemail'];
- $result = $database->addUser($username, $password, $email, $contactemail);
- echo "{ \"status\" : \"".$result."\" }";
- }
- else if($webQuery == "login")
- {
- $username = $_GET['username'];
- $password = $_GET['password'];
- $result = $database->login($username, $password);
- echo "{ \"status\" : \"".$result."\" }";
- }
- else if($webQuery == "addLocation")
- {
- $username = $_GET['username'];
- $password = $_GET['password'];
- $lat = $_GET['lat'];
- $lng = $_GET['lng'];
- $result = $database->addLocation($username, $password, $lat, $lng);
- echo "{ \"status\" : \"".$result."\" }";
- }
- else if($webQuery == "addtimer")
- {
- $username = $_GET['username'];
- $password = $_GET['password'];
- $interval = $_GET['interval'];
- $result = $database->addTimer($username, $password, $interval);
- echo "{ \"status\" : \"".$result."\" }";
- }
- else if($webQuery == "removetimer")
- {
- $username = $_GET['username'];
- $password = $_GET['password'];
- $result = $database->removeTimer($username, $password);
- echo "{ \"status\" : \"".$result."\" }";
- }
- else if($webQuery == "users")
- {
- $input = $_GET['input'];
- if($input != null)
- {
- $results = $database->getUsers($input);
- echo "{\"results\": [";
- $arr = array();
- while($row = mysql_fetch_array($results))
- {
- $arr[] = "{\"id\": \"" .$row['Id'] . "\", \"value\": \"" . $row['username'] . "\", \"info\": \"\"}";
- }
- echo implode(", ", $arr);
- echo "]}";
- }
- }
- else if($webQuery == "announcements")
- {
- $input = $_GET['input'];
- if($input != null)
- {
- $results = $database->query("SELECT News.Id, News.Title, News.Content FROM News WHERE News.Title LIKE '$input%' LIMIT 10");
- echo "{\"results\": [";
- $arr = array();
- while($row = mysql_fetch_array($results))
- {
- $arr[] = "{\"id\": \"" .$row['Id'] . "\", \"value\": \"" . $row['Title'] . "\", \"info\": \"" . $row['Content'] . "\"}";
- }
- echo implode(", ", $arr);
- echo "]}";
- }
- }
- else if($webQuery = "sexoffender")
- {
- $url = $_GET['url'];
- $url = urldecode($url);
- $url = str_replace(" ", "%20", $url);
- $r = new HttpRequest($url, HttpRequest::METH_GET);
- try {
- $r->send();
- if ($r->getResponseCode() == 200)
- {
- $json = json_decode($r->getResponseBody(), true);
- $arr = array();
- print("{identifier:'registrant',label:'registrant',items:[");
- for($i=0; $i<sizeof($json["records"]); $i++)
- {
- $arr[] = "{registrant:\"" . $json["records"][$i]["registrant"] .
- "\",oci:\"" . $json["records"][$i]["oci"] .
- "\",last_name:\"" . $json["records"][$i]["last_name"] .
- "\",first_name:\"" . $json["records"][$i]["first_name"] .
- "\",middle_name:\"" . $json["records"][$i]["middle_name"] .
- "\",gender:\"" . $json["records"][$i]["gender"] .
- "\",tier:\"" . $json["records"][$i]["tier"] .
- "\",county:\"" . $json["records"][$i]["county"] .
- "\",race:\"" . $json["records"][$i]["race"] .
- "\",hair_color:\"" . $json["records"][$i]["hair_color"] .
- "\",height_inches:\"" . $json["records"][$i]["height_inches"] .
- "\",weight_pounds:\"" . $json["records"][$i]["weight_pounds"] .
- "\",eye_color:\"" . $json["records"][$i]["eye_color"] .
- "\",skin_tone:\"" . $json["records"][$i]["skin_tone"] .
- "\",last_changed:\"" . $json["records"][$i]["last_changed"] .
- "\",address:\"" . $json["records"][$i]["address"] .
- "\",birthdate:\"" . $json["records"][$i]["birthdate"] .
- "\",lat:\"" . $json["records"][$i]["lat"] .
- "\",lon:\"" . $json["records"][$i]["lon"] .
- "\",victim_minors:\"" . $json["records"][$i]["victim_minors"] .
- "\",victim_adults:\"" . $json["records"][$i]["victim_adults"] .
- "\",victim_uknown:\"" . $json["records"][$i]["victim_uknown"] .
- "\",registrant_cluster:\"" . $json["records"][$i]["registrant_cluster"] .
- "\",photo:\"" . $json["records"][$i]["photo"] .
- "\",distance:\"" . $json["records"][$i]["distance"] .
- "\"}";
- }
- print(implode(",", $arr));
- print("]}");
- }
- } catch (HttpException $ex) {
- print($ex);
- }
- session_write_close();
- }
- else if($webQuery = "passthrough")
- {
- $url = $_GET['url'];
- $url = urldecode($url);
- $url = str_replace(" ", "%20", $url);
- $r = new HttpRequest($url, HttpRequest::METH_GET);
- try {
- $r->send();
- if ($r->getResponseCode() == 200) {
- print($r->getResponseBody());
- }
- } catch (HttpException $ex) {
- print($ex);
- }
- session_write_close();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement