". $aprs_path . $aprs_message ."\n"; if ($aprs_socket) { $aprs_result = socket_connect ($aprs_socket, $server, $port); if ($aprs_result) { socket_write ($aprs_socket, $aprs_login, strlen ($aprs_login)); $aprs_authstartat = time (); $aprs_authenticated = false; while ($msgin = socket_read ($aprs_socket, 1000, PHP_NORMAL_READ)) { if (strpos ($msgin, $aprs_callsign ." verified") !== FALSE) { $aprs_authenticated = true; echo "
". $msgin ."
"; break; } if (time () - $aprs_authstartat > 5) break; } if ($aprs_authenticated) { socket_write ($aprs_socket, $aprs_info, strlen ($aprs_info)); echo "". $aprs_info ."
"; } } } socket_close ($aprs_socket); } /* Database query */ function APIGetInfoFromFile ($id) { // ini_set ('allow_url_fopen', 1); // Allow extern URL $api_file = "data/stripped.csv"; // Database is local $api_array[6] = 0; // api array for results for ($i = 0; $i <= 6; $i++) // Clean the api set for new ids $api_array[$i] = "---"; if ($file = fopen ($api_file, "r")) { // Read the database file and return if id exist while (!feof ($file)) { $line = fgets ($file); $array = explode ($id, $line, 2); if (isset ($array[1])) // if exist, write into api set $api_array = explode (",", $array[1]); } fclose ($file); } header ('Content-Type: application/json'); // Prepare the data to result /* $api_data = '{ "results": [{ "callsign": "'. $api_array[1] .'", "fname": "'. $api_array[2] .'", "city": "'. $api_array[3] .'", "state": "'. $api_array[4] .'", "country": "'. $api_array[5] .'", "id": "'. $id .'" }] }'; */ $api_data = '{ "results": [{ "callsign": "'. $api_array[1] .'", "fname": "'. $api_array[2] .'", "id": "'. $id .'" }] }'; echo $api_data; // Print output on api page return $api_data; // Return data to openwebrx } error_reporting (0); if ($_GET["id"]) APIGetInfoFromFile ($_GET["id"]); else { if (isset ($_POST['server']) && isset ($_POST['port']) && isset ($_POST['callsign']) && isset ($_POST['passcode']) && isset ($_POST['lat']) && isset ($_POST['lon']) && isset ($_POST['comment']) && isset ($_POST['icon'])) APISendAPRSInfo ($_POST["server"], $_POST["port"], $_POST["callsign"], $_POST["passcode"], $_POST["lat"], $_POST["lon"], $_POST["comment"], $_POST["icon"]); else if (isset ($_POST['callsign'])) echo APIGetPasscode ($_POST["callsign"]); } ?>