"; $result = mysql_query("update inbox set Processed='true' WHERE ID='$id2[1]'"); $id = $id2[3]; } else { $result = mysql_query("update inbox set Processed='true' WHERE ID='$id'"); // echo $id; break; } } // echo "

"; } echo "\n\n"; echo "SMS\n"; $dbpass = @mysql_connect("$ip","$user","$pass"); if (!$dbpass) { echo "error connecting to db\n"; } else { //searching for sms in Inbox table from Gammu SMSD $result = mysql_db_query("$smsd_db","select $inbox from inbox where Processed='false' AND Coding NOT IN ('8bit')"); $counter_complete = 0; $counter_incomplete = 0; while($rekord = mysql_fetch_row($result)) { $udh = $rekord[5]; $complete = false; //we have single sms if ($udh == "") { copysms($rekord[8],$rekord[3],$rekord[1],$rekord[9]); $counter_complete++; } //we have linked sms with 8 bit ID (short UDH) if (strlen($udh) == 12 && $udh[0] == 0 && $udh[1] == 5 && $udh[2] == 0 && $udh[3] == 0 && $udh[4] == 0 && $udh[5] == 3 && $udh[10] == 0 && $udh[11] == 1) { $complete = true; $text = $rekord[8]; $id = $rekord[9]; //we search for all sms in sequence for ($i = 2; $i < ($udh[8]*10+$udh[9])+1; $i++) { $udh2 = "050003$udh[6]$udh[7]$udh[8]$udh[9]"; if ($i < 10) { $udh2 = "$udh2"."0$i"; } else { $udh2 = "$udh2"."$i"; } $result2 = mysql_db_query("sms","select $inbox from inbox where UDH='$udh2' AND SenderNumber='$rekord[3]' && SMSCNumber='$rekord[6]' && Processed='false'"); $rekord2 = mysql_fetch_row($result2); mysql_free_result($result2); if ($rekord2 != NULL) { $text="$text"."$rekord2[8]"; $id = "$id,"."$rekord2[9]"; } else { $counter_incomplete++; $complete = false; break; } } } //we have linked sms with 16 bit ID (long UDH) if (strlen($udh) == 14 && $udh[0] == 0 && $udh[1] == 6 && $udh[2] == 0 && $udh[3] == 8 && $udh[4] == 0 && $udh[5] == 4 && $udh[12] == 0 && $udh[13] == 1) { $text = $rekord[8]; $id = $rekord[9]; $complete = true; //we search for all sms in sequence for ($i = 2; $i < ($udh[10]*10+$udh[11])+1; $i++) { $udh2 = "060804$udh[6]$udh[7]$udh[8]$udh[9]$udh[10]$udh[11]"; if ($i < 10) { $udh2 = "$udh2"."0$i"; } else { $udh2 = "$udh2"."$i"; } $result2 = mysql_db_query("sms","select $inbox from inbox where UDH='$udh2' AND SenderNumber='$rekord[3]' && SMSCNumber='$rekord[6]' && Processed='false'"); $rekord2 = mysql_fetch_row($result2); mysql_free_result($result2); if ($rekord2 != NULL) { $text="$text"."$rekord2[8]"; $id = "$id,"."$rekord2[9]"; } else { $counter_incomplete++; $complete = false; break; } } } //all sms from linked sequence found if ($complete == true) { copysms($text,$rekord[3],$rekord2[1],$id); $counter_complete++; } } mysql_free_result($result); echo "$counter_complete SMS sequences processed correctly, "; echo "$counter_incomplete SMS sequences incomplete"; } echo ""; ?>