>>>> Unwanted output (e.g. text/warning/error) detected before \"UnwantedOutputCheckpoint($CheckpointNumber)\" in the script ".$_SERVER['PHP_SELF']); print("\r\n"); return true; } return false; } //------------------------------------------------------------- function ForwardTextData(&$pcGPS) { global $cgImeiDbgLogFile; $FileWriteData=''; for($DataPart=$Stored=0;$DataPart<$pcGPS->GetDataPartCount();$DataPart++,$Stored++) { if(!$pcGPS->SelectDataPart($DataPart) || !$pcGPS->IsValid()) { LogError($pcGPS->GetLastError().' data string: '.$pcGPS->GetHttpData()); continue; } { $Imei= $pcGPS->GetImei(); $FileWriteData.="IMEI=$Imei\t"; } { $Tmp = date('Y-m-d H:i:s', time()); $FileWriteData.="SDT=$Tmp\t"; } { $Time = $pcGPS->GetGpsTimeMySQL(); $FileWriteData.="DT=$Time\t"; } { $Swi = $pcGPS->GetSwitch(); $FileWriteData.="Swi=$Swi\t"; } if ($pcGPS->CanGetIndex() ) { $Tmp = $pcGPS->GetIndex(); $FileWriteData.="Seq=$Tmp\t"; } if ($pcGPS->CanGetLatLong() ) { $Tmp = $pcGPS->GetLatitudeFloat(); $FileWriteData.="Lat=$Tmp\t"; } if ($pcGPS->CanGetLatLong() ) { $Tmp = $pcGPS->GetLongitudeFloat(); $FileWriteData.="Lon=$Tmp\t"; } if ($pcGPS->CanGetLatLongMargin() ) { $Tmp = $pcGPS->GetLatLongMarginInMeters(); $FileWriteData.="LatLonMarg=$Tmp\t";} if ($pcGPS->CanGetAltitude() ) { $Tmp = $pcGPS->GetAltitudeInMeters(); $FileWriteData.="Alt=$Tmp\t"; } if ($pcGPS->CanGetAltitudeMargin()) { $Tmp = $pcGPS->GetAltitudeMarginInMeters(); $FileWriteData.="AltMrg=$Tmp\t"; } if ($pcGPS->CanGetHDOP() ) { $Tmp = $pcGPS->GetHDOP(); $FileWriteData.="HDOP=$Tmp\t"; } if ($pcGPS->CanGetHeading() ) { $Tmp = $pcGPS->GetHeading(); $FileWriteData.="Dir=$Tmp\t"; } if ($pcGPS->CanGetSpeed() ) { $Tmp = $pcGPS->GetSpeedKPH(); $FileWriteData.="Spd=$Tmp\t"; } if ($pcGPS->CanGetFix() ) { $Tmp = $pcGPS->GetFix(); $FileWriteData.="Fix=$Tmp\t"; } if ($pcGPS->CanGetAccu() ) { $Tmp = $pcGPS->GetAccu(); $FileWriteData.="Sup=$Tmp\t"; } if ($pcGPS->CanGetRev() ) { $Tmp = $pcGPS->GetRev(); $FileWriteData.="Rev=$Tmp\t"; } if ($pcGPS->CanGetVersion() ) { $Tmp = $pcGPS->GetVersion(); $FileWriteData.="Ver=$Tmp\t"; } if ($pcGPS->CanGetTemperature() ) { $Tmp = $pcGPS->GetTemperatureCelcius(); $FileWriteData.="Tmp=$Tmp\t"; } if ($pcGPS->CanGetIO() ) { $Tmp = $pcGPS->GetIO(); $FileWriteData.="IO=$Tmp\t"; } if ($pcGPS->CanGetIMSI() ) { $Tmp = $pcGPS->GetIMSI(); $FileWriteData.="IMSI=$Tmp\t"; } if ($pcGPS->CanGetLcdData() ) { $Tmp = bin2hex($pcGPS->GetLcdDataBytes()); $FileWriteData.="Cell=$Tmp\t"; } if ($pcGPS->CanGetSettingsCrc() ) { $Tmp = $pcGPS->GetSettingsCrc(); $FileWriteData.="SetCRC=$Tmp\t"; } if ($pcGPS->CanGetSettingsError() ) { $Tmp = $pcGPS->GetSettingsError(); $FileWriteData.="SetErr=$Tmp\t"; } if ($pcGPS->CanGetPortData() ) { $Tmp = bin2hex($pcGPS->GetPortDataBytes()); $FileWriteData.="Port=$Tmp\t"; } if ($pcGPS->CanGetReset() ) { $Rst = $pcGPS->GetReset(); $FileWriteData.="Reset=$Rst\t"; } if ($pcGPS->CanGetHardwareStatus()) { $Tmp = $pcGPS->GetHardwareStatus(); $FileWriteData.="HWStat=$Tmp\t"; } if ($pcGPS->CanGetMiscStatus() ) { $Tmp = $pcGPS->GetMiscStatus(); $FileWriteData.="MiscStat=$Tmp\t";} if ($pcGPS->CanGetRestartCause() ) { $Tmp = $pcGPS->GetRestartCause(); $FileWriteData.="Restart=$Tmp\t"; } if ($pcGPS->CanGetAnalogInputs() ) { $Tmp = $pcGPS->GetAnalogInput1(); $FileWriteData.="AnIn1=$Tmp\t"; } if ($pcGPS->CanGetAnalogInputs() ) { $Tmp = $pcGPS->GetAnalogInput2(); $FileWriteData.="AnIn2=$Tmp\t"; } if ($pcGPS->CanGetAnalogInputs() ) { $Tmp = $pcGPS->GetAnalogInput3(); $FileWriteData.="AnIn3=$Tmp\t"; } if ($pcGPS->CanGetAnalogInputs() ) { $Tmp = $pcGPS->GetAnalogInput4(); $FileWriteData.="AnIn4=$Tmp\t"; } if ($pcGPS->CanGetAnalogInput5() ) { $Tmp = $pcGPS->GetAnalogInput5(); $FileWriteData.="AnIn5=$Tmp\t"; } if ($pcGPS->CanGetAccelerationX() ) { $Tmp = $pcGPS->GetAccelerationX(); $FileWriteData.="AccX=$Tmp\t"; } if ($pcGPS->CanGetAccelerationY() ) { $Tmp = $pcGPS->GetAccelerationY(); $FileWriteData.="AccY=$Tmp\t"; } if ($pcGPS->CanGetAccelerationZ() ) { $Tmp = $pcGPS->GetAccelerationZ(); $FileWriteData.="AccZ=$Tmp\t"; } if ($pcGPS->CanGetGsmNetworkID() ) { $Tmp = $pcGPS->GetGsmNetworkID(); $FileWriteData.="GsmID=$Tmp\t"; } if ($pcGPS->CanGetSimPin() ) { $Tmp = $pcGPS->GetSimPin(); $FileWriteData.="SimPin=$Tmp\t"; } if ($pcGPS->CanGetPhoneNumber() ) { $Tmp = $pcGPS->GetPhoneNumber(); $FileWriteData.="PhoneNr=$Tmp\t"; } if ($pcGPS->CanGetGpsFirmwareCrc()) { $Tmp = $pcGPS->GetGpsFirmwareCrc(); $FileWriteData.="GpsCRC=$Tmp\t"; } if ($pcGPS->CanGetGsmFirmwareCrc()) { $Tmp = $pcGPS->GetGsmFirmwareCrc(); $FileWriteData.="GsmCRC=$Tmp\t"; } if ($pcGPS->CanGetGsmCGACT() ) { $Tmp = $pcGPS->GetGsmCGACT(); $FileWriteData.="GsmCGACT=$Tmp\t";} if ($pcGPS->CanGetGsmCGATT() ) { $Tmp = $pcGPS->GetGsmCGATT(); $FileWriteData.="GsmCGATT=$Tmp\t";} if ($pcGPS->CanGetGsmCREG() ) { $Tmp = $pcGPS->GetGsmCREG(); $FileWriteData.="GsmCREG=$Tmp\t"; } if ($pcGPS->CanGetEventID() ) { $Tmp = $pcGPS->GetEventID(); $FileWriteData.="EvtID=$Tmp\t"; } if ($pcGPS->CanGetShake() ) { $Tmp = $pcGPS->GetShake(); $FileWriteData.="Shake=$Tmp\t"; } if ($pcGPS->CanGetAdditionalIO() ) { $Tmp = $pcGPS->GetAdditionalIO(); $FileWriteData.="AddIO=$Tmp\t"; } if ($pcGPS->CanGetCounterTravelledMeters() ) { $Tmp = $pcGPS->GetCounterTravelledMeters(); $FileWriteData.="TravMtrs=$Tmp\t"; } if ($pcGPS->CanGetCounterTripMeters() ) { $Tmp = $pcGPS->GetCounterTripMeters(); $FileWriteData.="TripMtrs=$Tmp\t"; } if ($pcGPS->CanGetCounters() ) { $Tmp = $pcGPS->GetCounterSecondsActive(); $FileWriteData.="CntSecAct=$Tmp\t"; } if ($pcGPS->CanGetCounters() ) { $Tmp = $pcGPS->GetCounterSecondsMoving(); $FileWriteData.="CntSecMov=$Tmp\t"; } if ($pcGPS->CanGetGpsStatus() ) { $Tmp = $pcGPS->GetGpsStatus(); $FileWriteData.="GpsStat=$Tmp\t"; } if ($pcGPS->CanGetIButton() ) { $Tmp = $pcGPS->GetIButtonAttached(); $FileWriteData.="IButAttached=$Tmp\t"; } if ($pcGPS->CanGetIButtonSerialNumber()) { $Tmp = $pcGPS->GetIButtonSerialNumberText(); $FileWriteData.="IButSN=$Tmp\t"; } if ($pcGPS->CanGet1WireDS18B20temperature()) { $Tmp = $pcGPS->Get1WireDS18B20celcius(); $FileWriteData.="DS18B20=$Tmp\t"; } if ($pcGPS->CanGetHDOP() ) { $Tmp = $pcGPS->GetHDOP(); $FileWriteData.="HDOP=$Tmp\t"; } if ($pcGPS->CanGetView() ) { $Tmp = $pcGPS->GetView(); $FileWriteData.="View=$Tmp\t"; } if ($pcGPS->CanGetMaxDB() ) { $Tmp = $pcGPS->GetMaxDB(); $FileWriteData.="MaxDB=$Tmp\t"; } if ($pcGPS->CanGetGpsHighestMaxDB()){ $Tmp = $pcGPS->GetGpsHighestMaxDB(); $FileWriteData.="HighMaxDB=$Tmp\t"; } if ($pcGPS->CanGetFstr() ) { $Tmp = $pcGPS->GetFstr(); $FileWriteData.="Fstr=$Tmp\t"; } if ($pcGPS->CanGetPhoneNumber() ) { $Tmp = $pcGPS->GetPhoneNumber(); $FileWriteData.="PhoneNr=$Tmp\t"; } if ($pcGPS->CanGetUserCounter() ) { $Tmp = $pcGPS->GetUserCounter($CounterNumber); $FileWriteData.="UsrCntr=$Tmp\t"; } { $FileWriteData.="PHP=V18\r\n"; } } if(!strlen($FileWriteData)) return $Stored; //Number of items that the module does not need to resend $OK = OutputTextlogV14($Imei,$FileWriteData); if ($OK) return $Stored; return 0; // niet goed: traceme moet opnieuw } //------------------------------------------------------------- function GetBinLog($ModuleDataString, &$Imei, &$BinDate, &$TimeStamp) { $Con='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-'; $aParts=explode('*',$ModuleDataString); $Bin=''; for($Part=0;;$Part++) { if(!$Part) { $Imei=DecompressImei($aParts[0]); if((strlen($Imei)!=15)||strspn($Imei, '0123456789')!=15) { LogError("Invalid IMEI in custom string: $ModuleDataString"); return 0; } continue; } if(!isset($aParts[$Part])) { if(($Part-1)%5) { LogError("Part $Part is missing in custom string: $ModuleDataString"); return 0; } break; } $Enc=$aParts[$Part]; $Len=strlen($Enc); if(($Len!=44)||strspn($Enc, $Con)!=44) { LogError("Part $Part has invalid length or characters in custom string: $ModuleDataString"); return 0; } $Hex=''; for($i=0;$i<$Len;$i+=4) { $v1=strpos($Con,$Enc[$i]); $v2=strpos($Con,$Enc[$i+1]); $v3=strpos($Con,$Enc[$i+2]); $v4=strpos($Con,$Enc[$i+3]); $Hex.=sprintf('%06X',(($v1<<18)+($v2<<12)+($v3<<6)+$v4)); } if(!(($Part-1)%5)) { $TimeStamp=(((float)hexdec(substr($Hex,0,8))*16.0)/100.0)+946684800.0; $Bin.=gmdate('YmdHis', $TimeStamp); $BinDate =gmdate('Y-m-d H:i:s', $TimeStamp)."\r\n"; } $Len=$Hex; for($i=8;$i<62;$i+=2) { if($i==16) continue; //Switch $Bin.=chr(hexdec(substr($Hex,$i,2))); } } return $Bin; } //------------------------------------------------------------- // BODY //------------------------------------------------------------- if(UnwantedOutputCheckpoint(1)) exit(); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint if(!file_exists($CgpsClassFileName)) { LogError("The required file '$CgpsClassFileName' is missing."); exit(); } if(((include $CgpsClassFileName)!='included') || headers_sent()) { LogError("This file '$CgpsClassFileName' seems to be incompatible. Please upgrade the file."); exit(); } if(isset($_GET[$ReceiptionVariableName])) //Here we check if the script received data via the variable above { //Received module data, so store the received data in a variable $ModuleDataString=$_GET[$ReceiptionVariableName]; if(strpos($ModuleDataString,'*')!==false) { $Bin = GetBinLog($ModuleDataString,$Imei,$BinDate,$Time); if (!$Bin) exit(); LogText("$cgImeiDbgLogFile $Imei.log",date('Y-m-d H:i:s', time())." BinLog $BinDate"); $OK = OutputBinlogV14($Imei,$Bin); if (!$OK) exit(); if (UnwantedOutputCheckpoint(12345)) exit(); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint die("\r\n*A#G\r\nOK\r\n"); // acknowledge to traceme } //Get extra binary data if the module included it (e.g. picture data from a photo) //(Depending on the settings of your PHP setup, this data is also available via $HTTP_RAW_POST_DATA) $ExtraModuleData=@file_get_contents("php://input"); //Create an instance of the CGPS class and initialize it with the received module data. $pcGPS=new CGPS(); //Create new instance of the CGPS class. $pcGPS->ClearResponseActionMembers(); //Clear all response action members in the class by setting them to neutral. if(!$pcGPS->SetHttpData($ModuleDataString)) //Set class with received data. { //The class did not accept the received data. LogError($pcGPS->GetLastError()." Received data string: $ModuleDataString"); //Add message to the error log. UnwantedOutputCheckpoint(2); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint. print($pcGPS->BuildResponseHTTP(0)); //Makes the module retry later (assuming the transmission actually came from a module). exit(); //Silent script exit. } //Verify reported extra data size with the size of the actually received extra data. if($pcGPS->CanGetExtraDataSize() && ($pcGPS->GetExtraDataSize()!=strlen($ExtraModuleData))) { LogInfo(strlen($ExtraModuleData)." extra data were received Photo? Switch=".GetSwitch()); //The data size does not match the received data size. Presumable cause is some limiter or filter (e.g. proxy) in the network of your GPRS provider. LogError('Module says that '.$pcGPS->GetExtraDataSize().' bytes of extra data were included, while '.strlen($ExtraModuleData)." were received. Presumable cause is some limiter/filter/proxy (in the network of your GPRS provider) that modified the data. Received data string: $ModuleDataString"); UnwantedOutputCheckpoint(3); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint. print($pcGPS->BuildResponseHTTP(0)); //Let the module know that it was not accepted exit(); //Silent script exit. } // Begin foto opslaan if (($pcGPS->GetSwitch()==SV_PhotoGps)||($pcGPS->GetSwitch()==SV_Photo)) { $PhotoFileName='D:\\EDServer\\'.$pcGPS->GetImei().'_'.$pcGPS->GetUtcTimeMySQL().'_'.$pcGPS->GetLatitudeFloat().'_'.$pcGPS->GetLatitudeFloat().'.jpg'; if($hFile=@fopen($PhotoFileName, 'wb')) { LogInfo("Writing photo to $PhotoFileName"); fwrite($hFile, $ExtraModuleData); fclose(); } else LogError("Error creating photo file: $PhotoFileName"); } // Einde foto opslaan //Forward incoming extracted and converted into dedicated form to another script/computer/device. $NumberOfProcessedDataParts=ForwardTextData($pcGPS);//, $ExtraModuleData); if(UnwantedOutputCheckpoint(5)) exit(); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint. //### INFO ### uploading from your server to the module (e.g. new firmware, new settings, command's, port data). //Because we actually accepted stored the received data at this point, we and are going to respond that to the transmitting module. //But if you want, you can include extra tasks for the module to performed if you want. //You are likely going to keep track of things like new module settings and actions and that //are pending for each of your modules in a database. //But for simplicity's sake of this example, we use command files that you put in the same directory //as this script on your server. //Every time a module transmits to your server, this script checks if you have put a command file //for it !!!in the same directory!!! as this script. //If such a file exists, it is handled and deleted afterwards so the action is performed only once. //### WARNING ### It is important that your server grants this script the priorities required //to actually delete these files from the directory. //In the file name of such a command file, you use every module's unique 15 digit IMEI serial number to address them idividually. //See below for supported command file extensions and their discription/contents/function. if(!$pcGPS->IsForwardedByGateway()) //Did we receive the data directly from a module and not from a gateway that forwarded it? { $Imei=$pcGPS->GetImei(); //Extract the module's IMEI code like "123456789012345" to see if we created pending commads for it. //***NEW MODULE SETTINGS*** $FileName="$DownloadMap$Imei.tms"; //Construct file name like: 123456789012345.tms if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain settings from the CGPSsettings class or written to disk with the settings application. //When the new settings are received by the module, it will let the result know via a transmission type SV_SettingsAccepted or SV_SettingsRejected. $pcGPS->mSettings=@file_get_contents($FileName); LogInfo("Download TMS to $Imei from file \"$FileName\""); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } else { //***GPS ASSIST FILE?*** $FileName1="$DownloadMap"."$Imei.gps"; //Construct file name like: 123456789012345.tms $FileName2="$DownloadMap"."GPSAssist.txt"; //LogInfo("GPS files for $Imei from file \"$FileName1\",\"$FileName2\"\r\n"); if ( (@is_file($FileName1)) && //Does a file with this name exist in the same directory as this script? (@is_file($FileName2)) && ($pcGPS->CanGetFix() ) && ($pcGPS->GetFix()<3 ) ) { //The file is expected to contain settings from the CGPSsettings class or written to disk with the settings application. //When the new settings are received by the module, it will let the result know via a transmission type SV_SettingsAccepted or SV_SettingsRejected. $pcGPS->mSettings=@file_get_contents($FileName2); LogInfo("Download GPS to $Imei from file \"$FileName2\""); @chmod($FileName, 0777); if(!@unlink($FileName1)) LogError("!!!PROBLEM!!! The file '$FileName1' could not be deleted."); } } //***UPDATING FIRMWARE*** $FileName="$DownloadMap$Imei.tmf"; //Construct filename like: 123456789012345.tmf if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //An ASCII text file is expected, containing only the 3 digits of the new firmware version. //If the file exists and contains for example the following three digits: 385 //the module will try to download this file from your server: traceme385.hex //NOTES: //- The tracemeXXX.hex firmware file must be downloadable from the root directory of your HTTP server. // You can manually check if the file can be downloaded from your server's HTTP root // directory with a web browser by entering an URL like: http://YourServerIP/tracemeXXX.hex // You may need to configure your server's settings and/or add a new mime type // (e.g. binary octet-stream) before it allows downloads of binary files with the .hex // extension that you put in the HTTP root directory. //- A module will only reboot and start using downloaded firmware data if the version number // of the firmware is higher than the one already in use. //- Some GPRS providers use limits and filters in their system that can prohibit the module // from downloading a firmware file unmodified and in it's full length. // In this case you can only upload new firmware into a module with the settings program // via a direct cable connection. $FileSize=@filesize($FileName); if(($FileSize>=3) && $FileSize<=3+2) { $FirmwareVersion=@substr(@file_get_contents($FileName), 0, 3); if(@strspn($FirmwareVersion, '0123456789')==3) { $pcGPS->mFirmware=$FirmwareVersion; //Store firmware version in the response member of the class. LogInfo("Module $Imei has been instructed to download the firmware file \"traceme$FirmwareVersion.hex\" from the root of your HTTP server"); // LogInfo("Upload HEX to $Imei from file \"traceme$FirmwareVersion.hex\"\r\n"); } else LogError("Firmware command file \"$FileName\" contained invalid characters and must contain only the 3 digits of the firmware version."); } else LogError("Firmware command file \"$FileName\" file size was incorrect. It must contain only the 3 digits of the firmware version."); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } //***PERFORM ACTION*** $FileName="$DownloadMap$Imei.ra"; //Construct filename like: 123456789012345.ra if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //An ASCII text file is expected containing the action(s) that you want to be performed by the module. //All actions that you trigger in your file are set in the response action members of the CGPS class //and is used to build response that is send to the module to perform these actions. /************ copy lines below into your "123456789012345.ra" file ************ //Remove all the trigger lines below that do not want to be performed. GpsLog //Log current GPS position CountersLog //Log current reading of the counters TransmitLog //Transmit current log ResetTimer1 //Reset timer 1 ResetTimer2 //Reset timer 2 ResetTimer3 //Reset timer 3 ResetTimer4 //Reset timer 4 ResetTimer5 //Reset timer 5 ResetTimer6 //Reset timer 6 ResetTimer7 //Reset timer 7 ResetTimer8 //Reset timer 8 SmsAlert1 //Send an alert SMS message to phone number 1 SmsAlert2 //Send an alert SMS message to phone number 2 SmsAlert3 //Send an alert SMS message to phone number 3 SmsAlertCalledBy1 //Send an alert SMS message to "called by..." phone number 1 SmsAlertCalledBy2 //Send an alert SMS message to "called by..." phone number 2 SmsAlertCalledBy3 //Send an alert SMS message to "called by..." phone number 3 RebootModule //Force module reboot via watchdog. ***ALL*** active/pending actions will be terminated without finishing them. ClearGPSConfig //Clear configuration of the GPS receiver, resulting in a "cold start" position determination of the GPS receiver. ClearLog //Erase the FLASH memory in the module, clearing the log and uploaded user program/variables. //NOTE: If more than one trigger is used for the same item below, only the last one will be performed. Photo=HiRes //Take high resolution picture Photo=LoRes //Take low resolution picture DigitalOutput1=Enable //Enable digital output 1 DigitalOutput1=Disable //Disable digital output 1 DigitalOutput1=Toggle //Toggle digital output 1 DigitalOutput2=Enable //Enable digital output 2 DigitalOutput2=Disable //Disable digital output 2 DigitalOutput2=Toggle //Toggle digital output 2 DigitalOutput3=Enable //Enable digital output 3 DigitalOutput3=Disable //Disable digital output 3 DigitalOutput3=Toggle //Toggle digital output 3 DigitalOutput4=Enable //Enable digital output 4 DigitalOutput4=Disable //Disable digital output 4 DigitalOutput4=Toggle //Toggle digital output 4 ************* copy lines above into your "123456789012345.ra" file ************/ if(($ResponseActionFile=@file_get_contents($FileName)) && strlen($ResponseActionFile)) { $ActionResponseInfo=''; if(strpos($ResponseActionFile, 'GpsLog')!==false) {$pcGPS->mGpsLog=true; $ActionResponseInfo.='GpsLog|';} if(strpos($ResponseActionFile, 'CountersLog')!==false) {$pcGPS->mCountersLog=true; $ActionResponseInfo.='CountersLog|';} if(strpos($ResponseActionFile, 'TransmitLog')!==false) {$pcGPS->mTransmitLog=true; $ActionResponseInfo.='TransmitLog|';} if(strpos($ResponseActionFile, 'ResetTimer1')!==false) {$pcGPS->mResetTimer1=true; $ActionResponseInfo.='ResetTimer1|';} if(strpos($ResponseActionFile, 'ResetTimer2')!==false) {$pcGPS->mResetTimer2=true; $ActionResponseInfo.='ResetTimer2|';} if(strpos($ResponseActionFile, 'ResetTimer3')!==false) {$pcGPS->mResetTimer3=true; $ActionResponseInfo.='ResetTimer3|';} if(strpos($ResponseActionFile, 'ResetTimer4')!==false) {$pcGPS->mResetTimer4=true; $ActionResponseInfo.='ResetTimer4|';} if(strpos($ResponseActionFile, 'ResetTimer5')!==false) {$pcGPS->mResetTimer5=true; $ActionResponseInfo.='ResetTimer5|';} if(strpos($ResponseActionFile, 'ResetTimer6')!==false) {$pcGPS->mResetTimer6=true; $ActionResponseInfo.='ResetTimer6|';} if(strpos($ResponseActionFile, 'ResetTimer7')!==false) {$pcGPS->mResetTimer7=true; $ActionResponseInfo.='ResetTimer7|';} if(strpos($ResponseActionFile, 'ResetTimer8')!==false) {$pcGPS->mResetTimer8=true; $ActionResponseInfo.='ResetTimer8|';} if(strpos($ResponseActionFile, 'SmsAlert1')!==false) {$pcGPS->mSmsAlert1=true; $ActionResponseInfo.='SmsAlert1|';} if(strpos($ResponseActionFile, 'SmsAlert2')!==false) {$pcGPS->mSmsAlert2=true; $ActionResponseInfo.='SmsAlert2|';} if(strpos($ResponseActionFile, 'SmsAlert3')!==false) {$pcGPS->mSmsAlert3=true; $ActionResponseInfo.='SmsAlert3|';} if(strpos($ResponseActionFile, 'SmsAlertCalledBy1')!==false) {$pcGPS->mSmsAlertCalledBy1=true; $ActionResponseInfo.='SmsAlertCalledBy1|';} if(strpos($ResponseActionFile, 'SmsAlertCalledBy2')!==false) {$pcGPS->mSmsAlertCalledBy2=true; $ActionResponseInfo.='SmsAlertCalledBy2|';} if(strpos($ResponseActionFile, 'SmsAlertCalledBy3')!==false) {$pcGPS->mSmsAlertCalledBy3=true; $ActionResponseInfo.='SmsAlertCalledBy3|';} if(strpos($ResponseActionFile, 'RebootModule')!==false) {$pcGPS->mRebootModule=true; $ActionResponseInfo.='RebootModule|';} if(strpos($ResponseActionFile, 'ClearGPSConfig')!==false) {$pcGPS->mClearGPSConfig=true; $ActionResponseInfo.='ClearGPSConfig|';} if(strpos($ResponseActionFile, 'ClearLog')!==false) {$pcGPS->mClearLog=true; $ActionResponseInfo.='ClearLog|';} if(strpos($ResponseActionFile, 'DigitalOutput1=Enable')!==false) {$pcGPS->mDigitalOutput1=RACD_DigitalOutput_Enable; $ActionResponseInfo.='DigitalOutput1=Enable|';} if(strpos($ResponseActionFile, 'DigitalOutput1=Disable')!==false) {$pcGPS->mDigitalOutput1=RACD_DigitalOutput_Disable; $ActionResponseInfo.='DigitalOutput1=Disable|';} if(strpos($ResponseActionFile, 'DigitalOutput1=Toggle')!==false) {$pcGPS->mDigitalOutput1=RACD_DigitalOutput_Toggle; $ActionResponseInfo.='DigitalOutput1=Toggle|';} if(strpos($ResponseActionFile, 'DigitalOutput2=Enable')!==false) {$pcGPS->mDigitalOutput2=RACD_DigitalOutput_Enable; $ActionResponseInfo.='DigitalOutput2=Enable|';} if(strpos($ResponseActionFile, 'DigitalOutput2=Disable')!==false) {$pcGPS->mDigitalOutput2=RACD_DigitalOutput_Disable; $ActionResponseInfo.='DigitalOutput2=Disable|';} if(strpos($ResponseActionFile, 'DigitalOutput2=Toggle')!==false) {$pcGPS->mDigitalOutput2=RACD_DigitalOutput_Toggle; $ActionResponseInfo.='DigitalOutput2=Toggle|';} if(strpos($ResponseActionFile, 'DigitalOutput3=Enable')!==false) {$pcGPS->mDigitalOutput3=RACD_DigitalOutput_Enable; $ActionResponseInfo.='DigitalOutput3=Enable|';} if(strpos($ResponseActionFile, 'DigitalOutput3=Disable')!==false) {$pcGPS->mDigitalOutput3=RACD_DigitalOutput_Disable; $ActionResponseInfo.='DigitalOutput3=Disable|';} if(strpos($ResponseActionFile, 'DigitalOutput3=Toggle')!==false) {$pcGPS->mDigitalOutput3=RACD_DigitalOutput_Toggle; $ActionResponseInfo.='DigitalOutput3=Toggle|';} if(strpos($ResponseActionFile, 'DigitalOutput4=Enable')!==false) {$pcGPS->mDigitalOutput4=RACD_DigitalOutput_Enable; $ActionResponseInfo.='DigitalOutput4=Enable|';} if(strpos($ResponseActionFile, 'DigitalOutput4=Disable')!==false) {$pcGPS->mDigitalOutput4=RACD_DigitalOutput_Disable; $ActionResponseInfo.='DigitalOutput4=Disable|';} if(strpos($ResponseActionFile, 'DigitalOutput4=Toggle')!==false) {$pcGPS->mDigitalOutput4=RACD_DigitalOutput_Toggle; $ActionResponseInfo.='DigitalOutput4=Toggle|';} if(strpos($ResponseActionFile, 'Photo=HiRes')!==false) {$pcGPS->mPhoto=RACD_Photo_HiRes; $ActionResponseInfo.='Photo=HiRes|';} if(strpos($ResponseActionFile, 'Photo=LoRes')!==false) {$pcGPS->mPhoto=RACD_Photo_LoRes; $ActionResponseInfo.='Photo=LoRes|';} LogInfo("Action response sent to module $Imei: $ActionResponseInfo"); } else LogError("The file $FileName could not read or was empty"); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } //***Module Serial Port Output*** $FileName="$DownloadMap$Imei.sp1"; //Construct filename like: 123456789012345.sp1 for serial port #1 if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain the data that is to be sent via that serial port of the module. if(filesize($FileName)>256) //Safety check to prevent mistakes with large file sizes. LogError("The file size safety check rejected and deleted the file '$FileName' because it was too big."); else $pcGPS->mSerialPort1=@file_get_contents($FileName); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } $FileName="$DownloadMap$Imei.sp2"; //Construct filename like: 123456789012345.sp2 for serial port #2 if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain the data that is to be sent via that serial port of the module. if (filesize($FileName)>256) //Safety check to prevent mistakes with large file sizes. LogError("The file size safety check rejected and deleted the file '$FileName' because it was too big."); else $pcGPS->mSerialPort2=@file_get_contents($FileName); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } $FileName="$DownloadMap$Imei.sp3"; //Construct filename like: 123456789012345.sp3 for serial port #3 if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain the data that is to be sent via that serial port of the module. if (filesize($FileName)>256) //Safety check to prevent mistakes with large file sizes. LogError("The file size safety check rejected and deleted the file '$FileName' because it was too big."); else $pcGPS->mSerialPort3=@file_get_contents($FileName); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } $FileName="$DownloadMap$Imei.sp4"; //Construct filename like: 123456789012345.sp4 for serial port #4 if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain the data that is to be sent via that serial port of the module. if (filesize($FileName)>256) //Safety check to prevent mistakes with large file sizes. LogError("The file size safety check rejected and deleted the file '$FileName' because it was too big."); else $pcGPS->mSerialPort4=@file_get_contents($FileName); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } //***Source Code / LCD Menu*** $FileName="$DownloadMap$Imei.src"; //Construct file name like: 123456789012345.src if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain the source code that is to be executed by the module. //This source code can consist of a combination of things like: //- A full new program for example to generate a menu on the attached LCD dispay. //- One or more changes to variables of already executing code in the module at run-time. //- Replacement or additional parts of code for parts of the current code in the module. //- Execution of code parts that are included or already present in the module. $pcGPSCODE=new CGPSCODE(); //Create instance of the class if($pcGPSCODE->AddSourceCode(@file_get_contents($FileName))) //Add code in the file to the class { //Class accepted the source code, so it should be safe to upload it to the module. //First check if the upload needs to be stalled untill the next time. if(strlen($pcGPS->mSettings) && $pcGPSCODE->GetFirstServerUploadStallLine()) { //Uploading these items at the same time will lead to problems, so stall this source code upload for now. LogInfo("Temporarily stalled uploading source code from file '$FileName' to module $Imei."); } else { //Upload the source code into the action response class member. $pcGPS->mSourceCode=$pcGPSCODE->GetSourceCode(); //Asking it back from the class ensures that it is always properly formatted. // LogInfo("The following source code from file '$FileName' has been uploaded to module $Imei:\r\n".@file_get_contents($FileName)."\r\n"); LogInfo("Upload SRC to $Imei from file \"$FileName\"\r\n"); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } } else { LogError("Source code in the file '$FileName' for module $Imei has been rejected. Reason: ".$pcGPSCODE->GetLastError()."\r\n".@file_get_contents($FileName)); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } } } if(UnwantedOutputCheckpoint(6)) exit(); //Safety check to see if your code changes evoked any text/error/warning output in the execution before this checkpoint. //Build a response and return it to the transmitting module. //This response includes the acknowledge for the processed data parts (so the module will not send them again). //and the commands that are set via the response action member variables of the class. print($pcGPS->BuildResponseHTTP($NumberOfProcessedDataParts)); //Build and send the response to acknowledge. exit(); //Silent script exit }