Ejemplo n.º 1
0
 /**
  * set phone number
  * @param string $phone
  * @param boolean $SC 
  */
 public function setPhone($phone, $SC = FALSE)
 {
     $this->_phone = $phone;
     $clear = preg_replace('/([^a-c0-9\\*\\#]*)/', NULL, $phone);
     $this->_isAddress = !$SC;
     if ($this->getType()->getType() == SCA\Type::TYPE_ALPHANUMERICAL) {
         list($this->_size, $this->_encoded) = PDU\Helper::encode7bit($clear);
     } else {
         // get size
         // service center addres counting by octets OA or DA as length numbers
         $this->_size = $SC ? 1 + (strlen($clear) + 1) / 2 : strlen($clear);
         $this->_encoded = implode("", array_map(array('self', '_map_filter_encode'), str_split($clear)));
     }
 }
Ejemplo n.º 2
0
 /**
  * prepare parts of message
  * @throws Exception
  */
 protected function _prepareParts()
 {
     //
     $headerSize = self::HEADER_SIZE;
     $max = Helper::getLimit('normal');
     if ($this->_isUnicode) {
         // max length sms to unicode
         $max = Helper::getLimit('unicode');
         // can't compress message
         $this->getPdu()->getDcs()->setTextCompressed(FALSE)->setTextAlphabet(DCS::ALPHABET_UCS2);
         // type alphabet is UCS2
     }
     // if message is compressed
     if ($this->getPdu()->getDcs()->getTextCompressed()) {
         $max = Helper::getLimit('compress');
         $headerSize++;
     }
     $parts = $this->_splitMessage($max, $headerSize);
     $header = count($parts) > 1;
     $uniqid = rand(0, 65535);
     // message will be splited, need headers
     if ($header) {
         $this->getPdu()->getType()->setUdhi(1);
     }
     foreach ($parts as $index => $text) {
         $params = $header ? array('SEGMENTS' => count($parts), 'CURRENT' => $index + 1, 'POINTER' => $uniqid) : NULL;
         $part = NULL;
         $size = 0;
         switch ($this->getPdu()->getDcs()->getTextAlphabet()) {
             case DCS::ALPHABET_DEFAULT:
                 PDU::debug("Helper::encode7bit()");
                 list($size, $part) = Helper::encode7bit($text);
                 break;
             case DCS::ALPHABET_8BIT:
                 PDU::debug("Helper::encode8BitMessage()");
                 list($size, $part) = Helper::encode8Bit($text);
                 break;
             case DCS::ALPHABET_UCS2:
                 PDU::debug("Helper::encode16BitMessage()");
                 list($size, $part) = Helper::encode16Bit($text);
                 break;
             default:
                 throw new Exception("Unknown alphabet");
         }
         if ($header) {
             $size += $headerSize;
         }
         $this->_parts[] = new Data\Part($this, $part, $size, $params);
     }
 }