if ($signo == SIGINT || $signo == SIGTERM) { $tx->close(); unset($tx); exit; } } /* Main * a connection was openened. We send enquire_link to keep it up * and listen to SMS coming this way. */ // send the first enquire_link if start_enquire is set if ($tx->start_enquire) { $tx->sendPDU(0x15, "", $tx->sequence_number++); } while (true) { $sms = $tx->readSMS(); //check sms data if ($sms && isset($sms['source_addr']) && isset($sms['destination_addr'])) { $from = strlen($sms['source_addr']) == 11 ? substr($sms['source_addr'], 1) : $sms['source_addr']; $short_code = $sms['destination_addr']; // check where the message is stored in short_messsage or message_payload if (!isset($sms['short_message']) || $sms['sm_length'] != strlen($sms['short_message']) || $sms['sm_length'] == 0) { if (isset($sms['sar_total_segments']) && isset($sms['sar_segment_seqnum'])) { if ($sms['sar_total_segments'] - $sms['sar_segment_seqnum'] == 0) { //if it's the last part of payload, accumlate $text = $sms['user_defined_payload']; unset($sms['user_defined_payload']); } else { continue; } } else {