Beispiel #1
0
 public function listAll()
 {
     $st = new SIPTrunk();
     $stf = new SIPTrunkForm();
     $stf->setEntity($st);
     $stf->setLogin($this->login);
     $this->initLogin();
     $u2 = $stf->getListAllURL();
     $this->curl->get($u2);
     return ParserSIPTrunk::getListObject($this->curl->response, $this->login);
 }
Beispiel #2
0
 public static function getListObject($html, $login)
 {
     $ao = new ArrayObject();
     $dom = HtmlDomParser::str_get_html($html);
     $e = $dom->find('div[class=rnav] ul');
     //find list sip
     foreach ($e as $ul) {
         //loop ul to extract li
         foreach ($ul->find('li') as $v2) {
             //loop li to extract plain text
             $val1 = $v2->innertext;
             //get plain text
             $regexp = "<a\\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>";
             if (preg_match_all("/{$regexp}/siU", $val1, $matches, PREG_SET_ORDER)) {
                 if ($matches[0][3] != "Add Trunk") {
                     $id1 = str_replace('config.php?display=trunks&', '', $matches[0][2]);
                     $id2 = str_replace('amp;extdisplay=', '', $id1);
                     $trunk = new Trunk();
                     //create new object sip
                     $self = new ParserSIPTrunk();
                     $trunk->extdisplay = $id2;
                     $trunk->trunkName = $self->getTrunkName($login, $id2);
                     $trunk->outCID = $self->getOutCID($login, $id2);
                     $trunk->peerHost = $self->getPeerHost($login, $id2);
                     $trunk->peerPassword = $self->getPeerPassword($login, $id2);
                     $trunk->peerUsername = $self->getPeerUsername($login, $id2);
                     $ao->append($trunk);
                     //append sip object to arrayObject
                 }
             }
         }
     }
     return $ao;
 }