Beispiel #1
0
 private function sentenceWrapper(SentenceUtil $sentence)
 {
     $it = $sentence->getBuildCommand()->getIterator();
     $attr = null;
     $main = new \ArrayObject();
     $append = new \ArrayObject();
     while ($it->valid()) {
         if (Util::contains($it->current()->getClause(), "commandPrint") || Util::contains($it->current()->getClause(), "commandReguler")) {
             if ($attr == null) {
                 $main->append($it->current());
             }
         } else {
             //if contains neither then add to append commands
             $append->append($it->current());
         }
         $it->next();
     }
     foreach ($append->getIterator() as $a) {
         $main->append($a);
     }
     /*
     
             $it->rewind();
     
             while ($it->valid()) {
                 if (!Util::contains($it->current()->getClause(), "commandPrint") &&
                     !Util::contains($it->current()->getClause(), "commandReguler")) {
                 }
                 $it->next();
             }
     */
     return $main;
 }
 /**
  * This method used for delete firewall connection
  * @param type $id string
  * @return type array
  */
 public function delete($id)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ip/firewall/connection/remove");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     return "Sucsess";
 }
Beispiel #3
0
 /**
  * This method is used to delete ppp active
  * @param type $id string
  * @return type array
  */
 public function delete($id)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ppp/active/remove");
     $sentence->where(".id", "=", $id);
     $enable = $this->talker->send($sentence);
     return "Sucsess";
 }
Beispiel #4
0
 /**
  *
  * This method used for set Web Proxy configuration
  * @param array $param
  * @return array
  */
 public function set($param)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ip/proxy/set");
     foreach ($param as $name => $value) {
         $sentence->setAttribute($name, $value);
     }
     $this->talker->send($sentence);
     return "Success";
 }
Beispiel #5
0
 /**
  * This method is used to display hotspot cookie
  * in detail based on the id
  * @param string $id 
  * @return  array
  *  
  */
 public function detail($id)
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/hotspot/cookie/print");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No IP Hotspot Cookie With This id = " . $id;
     }
 }
 /**
  *
  * @param type $id string 
  * @return type array
  * 
  */
 public function detail($id)
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/firewall/service-port/print");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Ip Firewall Service-Port With This id = " . $id;
     }
 }
Beispiel #7
0
 private function sentenceWrapper(SentenceUtil $sentence)
 {
     $it = $sentence->getBuildCommand()->getIterator();
     $attr = new Attribute();
     while ($it->valid()) {
         if (Util::contains($it->current()->getClause(), "commandPrint") || Util::contains($it->current()->getClause(), "commandReguler")) {
             $attr = $it->current();
         }
         $it->next();
     }
     $it->rewind();
     $out = new \ArrayObject();
     $out->append($attr);
     while ($it->valid()) {
         if (!Util::contains($it->current()->getClause(), "commandPrint") && !Util::contains($it->current()->getClause(), "commandReguler")) {
             $out->append($it->current());
         }
         $it->next();
     }
     return $out;
 }
Beispiel #8
0
 /**
  * This method is used to set ppp aaa
  * @param type $use_radius string
  * @param type $accounting string
  * @param type $interim_update string
  * @return type array
  */
 public function set($use_radius, $accounting, $interim_update)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ppp/aaa/set");
     $sentence->setAttribute("use-radius", $use_radius);
     $sentence->setAttribute("accounting", $accounting);
     $sentence->setAttribute("interim-update", $interim_update);
     $this->talker->send($sentence);
     return "Sucsess";
 }
 /**
  * This method is used to display one layer7 protocol
  * in detail based on the id
  * @param type $id string
  * @return type array
  * 
  */
 public function detail($id)
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/firewall/layer7-protocol/print");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No IP Firewall Layer7 Protocol With This id = " . $id;
     }
 }
Beispiel #10
0
 /**
  * This method used for get all interface Bridge Settings
  * @return type array
  */
 public function get_all_bridge_settings()
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/interface/bridge/settings/getall");
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Interface Bridge Settings To Set, Please Your Add Interface Bridge Settings";
     }
     return $this->query('');
 }
Beispiel #11
0
 /**
  * This method is used to display one vlan
  * in detail based on the id
  * @param type $id string
  * @return type array
  * 
  */
 public function detail($id)
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/interface/vlan/print");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Interface VLAN With This id = " . $id;
     }
 }
Beispiel #12
0
 /**
  * This method used for set l2tp server server
  * @param type $param array
  * @return type array
  */
 public function setServer($param)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/interface/l2tp-server/server/set");
     foreach ($param as $name => $value) {
         $sentence->setAttribute($name, $value);
     }
     $this->talker->send($sentence);
     return "Sucsess";
 }
Beispiel #13
0
 /**
  * This method is used to system reset configuration
  * @param type $keep_users string (yes or no)
  * @param type $no_defaults string (yes or no)
  * @param type $skip_backup string (yes or no)
  * @return type array
  */
 public function reset($keep_users, $no_defaults, $skip_backup)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ip/address/add");
     $sentence->setAttribute("keep-users", $keep_users);
     $sentence->setAttribute("no-defaults", $no_defaults);
     $sentence->setAttribute("skip-backup", $skip_backup);
     $this->talker->send($sentence);
     return "Success";
 }
Beispiel #14
0
 /**
  * This method is used to display one dns cache all 
  * in detail based on the id
  * @param type $id string
  * @return type array
  * 
  */
 public function detailCacheAll($id)
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/dns/cache/all/print");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Ip DNS Cache All With This Id = " . $id;
     }
 }
Beispiel #15
0
 /**
  * This method used for get all Ip Firewall Mangle
  * @return type array
  */
 public function getAll()
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/firewall/mangle/getall");
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Ip Firewall Mangle To Set, Please Your Add Ip Firewall Mangle";
     }
 }
Beispiel #16
0
 /**
  * This method is used to delete interface bonding by id
  * 
  * $this->mikrotik_api->interfaces()->bonding()->delete('*1');
  * @param type $id string
  * @return type array
  */
 public function delete($id)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/interface/bonding/remove");
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     return "Sucsess";
 }
Beispiel #17
0
 public function create_file($filename, $content)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand('[/lua "local f=assert(io.open(/' . $filename . ', w+));');
     $sentence->addCommand('f:write(' . $content . ');');
     $sentence->addCommand('f:close();');
     $this->talker->send($sentence);
     return "Success";
 }
Beispiel #18
0
 /**
  * This method is used to ip accounting set web-acces
  * @param type $accessible_via_web string default : yes or no
  * @return type array
  * 
  */
 public function set_web_access($accessible_via_web)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ip/accounting/web-access/set");
     $sentence->setAttribute("accessible-via-web", $accessible_via_web);
     $sentence->setAttribute("address", "0.0.0.0/0");
     $this->talker->send($sentence);
     return "Success";
 }
Beispiel #19
0
 /**
  * 
  * @param array $param
  * @param string $id
  * @return string
  */
 public function set($param, $id)
 {
     $sentence = new SentenceUtil();
     $sentence->addCommand("/ip/service/set");
     foreach ($param as $name => $value) {
         $sentence->setAttribute($name, $value);
     }
     $sentence->where(".id", "=", $id);
     $this->talker->send($sentence);
     return "Sucsess";
 }
 /**
  * This method used for get all system scheduler
  * @return type array
  */
 public function getAll()
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/system/scheduler/getall");
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No System Scheduler To Set, Please Your Add System Scheduler";
     }
 }
Beispiel #21
0
 /**
  * This method used for get all interface ppp-sever
  * @return array
  */
 public function getAll()
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/interface/ppp-server/getall");
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Interface PPP Server To Set, Please Your Add Interface PPP Server";
     }
 }
Beispiel #22
0
 /**
  * This method is used to display all ip dhcp relay
  * @return type array
  */
 public function getAll()
 {
     $sentence = new SentenceUtil();
     $sentence->fromCommand("/ip/dhcp-relay/getall");
     $this->talker->send($sentence);
     $rs = $this->talker->getResult();
     $i = 0;
     if ($i < $rs->size()) {
         return $rs->getResultArray();
     } else {
         return "No Ip Dhcp-Relay To Set, Please Your Add Ip Dhcp-Relay";
     }
 }