コード例 #1
0
ファイル: TalkerSender.php プロジェクト: xwiz/mikrotik-api
 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;
 }
コード例 #2
0
 /**
  * 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";
 }
コード例 #3
0
ファイル: Active.php プロジェクト: beecode/mikrotik-api
 /**
  * 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";
 }
コード例 #4
0
ファイル: WebProxy.php プロジェクト: xwiz/mikrotik-api
 /**
  *
  * 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";
 }
コード例 #5
0
ファイル: HotspotCookies.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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;
     }
 }
コード例 #6
0
 /**
  *
  * @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;
     }
 }
コード例 #7
0
ファイル: TalkerSender.php プロジェクト: beecode/mikrotik-api
 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;
 }
コード例 #8
0
ファイル: AAA.php プロジェクト: beecode/mikrotik-api
 /**
  * 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";
 }
コード例 #9
0
 /**
  * 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;
     }
 }
コード例 #10
0
ファイル: Bridge.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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('');
 }
コード例 #11
0
ファイル: VLAN.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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;
     }
 }
コード例 #12
0
ファイル: L2TPServer.php プロジェクト: beecode/mikrotik-api
 /**
  * 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";
 }
コード例 #13
0
ファイル: System.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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";
 }
コード例 #14
0
ファイル: DNS.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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;
     }
 }
コード例 #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";
     }
 }
コード例 #16
0
ファイル: Bonding.php プロジェクト: beecode/mikrotik-api
 /**
  * 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";
 }
コード例 #17
0
ファイル: File.php プロジェクト: xwiz/mikrotik-api
 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";
 }
コード例 #18
0
ファイル: Accounting.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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";
 }
コード例 #19
0
ファイル: Service.php プロジェクト: beecode/mikrotik-api
 /**
  * 
  * @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";
 }
コード例 #20
0
 /**
  * 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";
     }
 }
コード例 #21
0
ファイル: PPPServer.php プロジェクト: beecode/mikrotik-api
 /**
  * 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";
     }
 }
コード例 #22
0
ファイル: DHCPRelay.php プロジェクト: xwiz/mikrotik-api
 /**
  * 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";
     }
 }