<?php
// Utility sample for Aspicore GSM Tracker
// Show URL arguments as plain text and stores data into text file
// This sample demonstrates, how Aspicore GSM Tracker sends location data to the server via HTTP.
// Usage: Set "Internet page URL" in Aspicore GSM Tracker settings to point to this page.
//        You see the output in your phone in the Info tab every time the phone sends
//        some location data to the server via a HTTP connection.
// (c) Aspicore Ltd 2005, www.aspicore.com
// Tested with PHP 5.0.3, Windows XP, IIS 5.1 and with Windows Server 2003, IIS 6.0
// NB. If you are using PHP with IIS, set output_buffering = On in php.ini
// ------------------------------
// Change History:
// 2005-04-01 jje - SQL script created

header("Expires: 0");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Content-Type: text/plain; charset=ISO-8859-1");
header('Content-Disposition: inline; filename="response.txt"');

// Show time and arguments in the response to the HTTP client

$timestamp = gmdate("D, d M Y H:i:s");
echo
$timestamp;
echo
"\r\n" ;

print_r($_GET);
echo
"\r\n" ;

// Store new data into local text file

$output = print_r($_GET, true);
$output = str_replace ("\n", "\r\n", $output);    // Add "\r" characters for Windows

$filename = "C:/PHP/uploadtemp/storedata.txt";

if (!
$handle = fopen($filename, 'a')) {
    echo
"Cannot open file ($filename)";
    exit;
}

if (
fwrite($handle, "\r\n$timestamp\r\n") === FALSE) {
    echo
"Cannot write timestamp to file ($filename)";
    exit;
}

if (
fwrite($handle, $output) === FALSE) {
    echo
"Cannot write arguments to file ($filename)";
    exit;
}

fclose($handle);

?>