├── .gitignore
├── LICENSE
├── README.md
├── composer.json
├── nbproject
├── project.properties
└── project.xml
├── src
└── MikrotikAPI
│ ├── Commands
│ ├── File
│ │ └── File.php
│ ├── IP
│ │ ├── ARP.php
│ │ ├── Accounting.php
│ │ ├── Address.php
│ │ ├── DHCPClient.php
│ │ ├── DHCPRelay.php
│ │ ├── DHCPServer.php
│ │ ├── DNS.php
│ │ ├── Firewall
│ │ │ ├── Firewall.php
│ │ │ ├── FirewallAddressList.php
│ │ │ ├── FirewallConnection.php
│ │ │ ├── FirewallFilter.php
│ │ │ ├── FirewallLayer7Protocol.php
│ │ │ ├── FirewallMangle.php
│ │ │ ├── FirewallNAT.php
│ │ │ └── FirewallServicePort.php
│ │ ├── Hotspot
│ │ │ ├── Hotspot.php
│ │ │ ├── HotspotActive.php
│ │ │ ├── HotspotCookies.php
│ │ │ ├── HotspotHosts.php
│ │ │ ├── HotspotIPBindings.php
│ │ │ ├── HotspotServer.php
│ │ │ ├── HotspotServerProfiles.php
│ │ │ ├── HotspotUserProfiles.php
│ │ │ └── HotspotUsers.php
│ │ ├── IP.php
│ │ ├── Pool.php
│ │ ├── Route.php
│ │ ├── Service.php
│ │ └── WebProxy.php
│ ├── Interfaces
│ │ ├── Bonding.php
│ │ ├── Bridge.php
│ │ ├── EoIP.php
│ │ ├── Ethernet.php
│ │ ├── IPTunnel.php
│ │ ├── Interfaces.php
│ │ ├── L2TPClient.php
│ │ ├── L2TPServer.php
│ │ ├── PPPClient.php
│ │ ├── PPPServer.php
│ │ ├── PPPoEClient.php
│ │ ├── PPPoEServer.php
│ │ ├── PPTPClient.php
│ │ ├── PPTPServer.php
│ │ ├── VLAN.php
│ │ └── VRRP.php
│ ├── PPP
│ │ ├── AAA.php
│ │ ├── Active.php
│ │ ├── PPP.php
│ │ ├── Profile.php
│ │ └── Secret.php
│ └── System
│ │ ├── System.php
│ │ └── SystemScheduler.php
│ ├── Core
│ ├── Connector.php
│ ├── StreamReciever.php
│ └── StreamSender.php
│ ├── Entity
│ ├── Attribute.php
│ └── Auth.php
│ ├── MikrotikAPI.php
│ ├── Talker
│ ├── Talker.php
│ ├── TalkerReciever.php
│ └── TalkerSender.php
│ └── Util
│ ├── DebugDumper.php
│ ├── ResultUtil.php
│ ├── SentenceUtil.php
│ └── Util.php
├── test
└── test.php
└── vendor
├── autoload.php
└── composer
├── ClassLoader.php
├── autoload_classmap.php
├── autoload_namespaces.php
└── autoload_real.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /nbproject/private/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Lalu Erfandi Maula Yusnu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nunenuh/mikrotik-api/82ad5e43e8d06fb534508d66d161705ee258bf46/README.md
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nunenuh/mikrotik-api",
3 | "description": "Mikrotik API PHP Library for working with RouterOS API",
4 | "version": "0.8.0",
5 | "type": "library",
6 | "time": "2013-12-03",
7 | "keywords": ["API", "Mikrotik","RouterOS"],
8 | "license": "MIT",
9 | "authors": [
10 | {
11 | "name": "Lalu Erfandi Maula Yusnu",
12 | "email": "nunenuh@gmail.com",
13 | "homepage": "http://nunenuh.web.id"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-0": {
18 | "MikrotikAPI": "src/",
19 | "MikrotikAPITest": "test/"
20 | }
21 | },
22 | "require": {
23 | "php": ">=5.3.3"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | include.path=${php.global.include.path}
2 | php.version=PHP_53
3 | source.encoding=UTF-8
4 | src.dir=.
5 | tags.asp=false
6 | tags.short=false
7 | web.root=.
8 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.php.project
4 |
5 |
6 | mikrotik-api
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/File/File.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class File {
17 |
18 | /**
19 | * @access private
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to display all file in mikrotik RouterOs
30 | * @return type array
31 | */
32 | public function get_all_file() {
33 | $sentence = new SentenceUtil();
34 | $sentence->fromCommand("/file/getall");
35 | $this->talker->send($sentence);
36 | $rs = $this->talker->getResult();
37 | $i = 0;
38 | if ($i < $rs->size()) {
39 | return $rs->getResultArray();
40 | } else {
41 | return "No File";
42 | }
43 | }
44 |
45 | /**
46 | * This method is used to display one file
47 | * in detail based on the id
48 | * @param type $id string
49 | * @return type array
50 | */
51 | public function detail_file($id) {
52 | $sentence = new SentenceUtil();
53 | $sentence->fromCommand("/file/print");
54 | $sentence->where(".id", "=", $id);
55 | $this->talker->send($sentence);
56 | $rs = $this->talker->getResult();
57 | $i = 0;
58 | if ($i < $rs->size()) {
59 | return $rs->getResultArray();
60 | } else {
61 | return "No File With This id = " . $id;
62 | }
63 | }
64 |
65 | /**
66 | * This method is used to delete file by id
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete_file($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/file/remove");
73 | $sentence->where(".id", "=", $id);
74 | $enable = $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/ARP.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class ARP {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add arp
30 | * @param type $param array
31 | * @return type array
32 | * j
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/ip/arp/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to delete arp by id
46 | * @param type $id string
47 | * @return type array
48 | *
49 | */
50 | public function delete($id) {
51 | $sentence = new SentenceUtil();
52 | $sentence->addCommand("/ip/arp/remove");
53 | $sentence->where(".id", "=", $id);
54 | $enable = $this->talker->send($sentence);
55 | return "Sucsess";
56 | }
57 |
58 | /**
59 | * This method is used to enable arp by id
60 | * @param type $id string
61 | * @return type array
62 | *
63 | */
64 | public function enable($id) {
65 | $sentence = new SentenceUtil();
66 | $sentence->addCommand("/ip/arp/enable");
67 | $sentence->where(".id", "=", $id);
68 | $enable = $this->talker->send($sentence);
69 | return "Sucsess";
70 | }
71 |
72 | /**
73 | * This method is used to disable arp by id
74 | * @param type $id string
75 | * @return type array
76 | *
77 | */
78 | public function disable($id) {
79 | $sentence = new SentenceUtil();
80 | $sentence->addCommand("/ip/arp/disable");
81 | $sentence->where(".id", "=", $id);
82 | $disable = $this->talker->send($sentence);
83 | return "Sucsess";
84 | }
85 |
86 | /**
87 | * This method is used to set or edit by id
88 | * @param type $param array
89 | * @param type $id string
90 | * @return type array
91 | *
92 | */
93 | public function set($param, $id) {
94 | $sentence = new SentenceUtil();
95 | $sentence->addCommand("/ip/arp/set");
96 | foreach ($param as $name => $value) {
97 | $sentence->setAttribute($name, $value);
98 | }
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to display all arp
106 | * @return type array
107 | *
108 | */
109 | public function getAll() {
110 | $sentence = new SentenceUtil();
111 | $sentence->fromCommand("/ip/arp/getall");
112 | $this->talker->send($sentence);
113 | $rs = $this->talker->getResult();
114 | $i = 0;
115 | if ($i < $rs->size()) {
116 | return $rs->getResultArray();
117 | } else {
118 | return "No Ip ARP To Set, Please Your Add Ip ARP";
119 | }
120 | }
121 |
122 | /**
123 | * This method is used to display arp
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/ip/arp/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Ip ARP With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Accounting.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Accounting {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to set or edit ip accountng
30 | * @param type $account_local_traffic string
31 | * @param type $enabled string
32 | * @param type $threshold string
33 | * @return type array
34 | */
35 | public function setAccounting($account_local_traffic, $enabled, $threshold) {
36 | $sentence = new SentenceUtil();
37 | $sentence->addCommand("/ip/accounting/set");
38 | $sentence->setAttribute("account-local-traffic", $account_local_traffic);
39 | $sentence->setAttribute("enabled", $enabled);
40 | $sentence->setAttribute("threshold", $threshold);
41 | $this->talker->send($sentence);
42 | return "Sucsess";
43 | }
44 |
45 | /**
46 | * This method is used to display all accounting
47 | * @return type array
48 | *
49 | */
50 | public function getAll_accounting() {
51 | $sentence = new SentenceUtil();
52 | $sentence->fromCommand('/ip/accounting/getall');
53 | $this->talker->send($sentence);
54 | $rs = $this->talker->getResult();
55 | $i = 0;
56 | if ($i < $rs->size()) {
57 | return $rs->getResultArray();
58 | } else {
59 | return "No Ip Accounting To Set, Please Your Add Ip Accounting";
60 | }
61 | }
62 |
63 | /**
64 | * This method is used to display all snapshot
65 | * @return type array
66 | *
67 | */
68 | public function get_all_snapshot() {
69 | $sentence = new SentenceUtil();
70 | $sentence->fromCommand('/ip/accounting/snapshot/getall');
71 | $this->talker->send($sentence);
72 | $rs = $this->talker->getResult();
73 | $i = 0;
74 | if ($i < $rs->size()) {
75 | return $rs->getResultArray();
76 | } else {
77 | return "No Ip Accounting Snapshot To Set, Please Your Add Ip Accounting Snapshot";
78 | }
79 | }
80 |
81 | /**
82 | * This method is used to display all uncounted
83 | * @return type array
84 | *
85 | */
86 | public function get_all_uncounted() {
87 | $sentence = new SentenceUtil();
88 | $sentence->fromCommand('/ip/accounting/uncounted/getall');
89 | $this->talker->send($sentence);
90 | $rs = $this->talker->getResult();
91 | $i = 0;
92 | if ($i < $rs->size()) {
93 | return $rs->getResultArray();
94 | } else {
95 | return "No Ip Accounting Uncounted To Set, Please Your Add Ip Accounting Uncounted";
96 | }
97 | }
98 |
99 | /**
100 | * This method is used to display all web-acces
101 | * @return type array
102 | *
103 | */
104 | public function get_all_web_access() {
105 | $sentence = new SentenceUtil();
106 | $sentence->fromCommand('/ip/accounting/web-access/getall');
107 | $this->talker->send($sentence);
108 | $rs = $this->talker->getResult();
109 | $i = 0;
110 | if ($i < $rs->size()) {
111 | return $rs->getResultArray();
112 | } else {
113 | return "No Ip Accounting web-access To Set, Please Your Add Ip Accounting web-access";
114 | }
115 | }
116 |
117 | /**
118 | * This method is used to ip accounting set web-acces
119 | * @param type $accessible_via_web string default : yes or no
120 | * @return type array
121 | *
122 | */
123 | public function set_web_access($accessible_via_web) {
124 | $sentence = new SentenceUtil();
125 | $sentence->addCommand("/ip/accounting/web-access/set");
126 | $sentence->setAttribute("accessible-via-web", $accessible_via_web);
127 | $sentence->setAttribute("address", "0.0.0.0/0");
128 | $this->talker->send($sentence);
129 | return "Sucsess";
130 | }
131 |
132 | }
133 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Address.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Address {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add the ip address
30 | * @param type $address string
31 | * @param type $interface string
32 | * @param type $comment string
33 | * @return type array
34 | */
35 | public function add($param) {
36 | $sentence = new SentenceUtil();
37 | $sentence->addCommand("/ip/address/add");
38 | foreach ($param as $name => $value) {
39 | $sentence->setAttribute($name, $value);
40 | }
41 | $this->talker->send($sentence);
42 | return "Sucsess";
43 | }
44 |
45 | /**
46 | * This method is used to display all ip address
47 | * @return type array
48 | *
49 | */
50 | public function getAll() {
51 | $sentence = new SentenceUtil();
52 | $sentence->fromCommand("/ip/address/getall");
53 | $this->talker->send($sentence);
54 | $rs = $this->talker->getResult();
55 | $i = 0;
56 | if ($i < $rs->size()) {
57 | return $rs->getResultArray();
58 | } else {
59 | return "No Ip Address To Set, Please Your Add Ip Address";
60 | }
61 | }
62 |
63 | /**
64 | * This method is used to activate the ip address by id
65 | * @param type $id is not an array
66 | * @return type array
67 | *
68 | *
69 | */
70 | public function enable($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/ip/address/enable");
73 | $sentence->where(".id", "=", $id);
74 | $enable = $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method is used to disable ip address by id
80 | * @param type $id string
81 | * @return type array
82 | *
83 | *
84 | */
85 | public function disable($id) {
86 | $sentence = new SentenceUtil();
87 | $sentence->addCommand("/ip/address/disable");
88 | $sentence->where(".id", "=", $id);
89 | $this->talker->send($sentence);
90 | return "Sucsess";
91 | }
92 |
93 | /**
94 | * This method is used to remove the ip address by id
95 | * @param type $id is not an array
96 | * @return type array
97 | *
98 | */
99 | public function delete($id) {
100 | $sentence = new SentenceUtil();
101 | $sentence->addCommand("/ip/address/remove");
102 | $sentence->where(".id", "=", $id);
103 | $enable = $this->talker->send($sentence);
104 | return "Sucsess";
105 | }
106 |
107 | /**
108 | * This method is used to set or edit by id
109 | * @param type $param array
110 | * @return type array
111 | *
112 | */
113 | public function set($param, $id) {
114 | $sentence = new SentenceUtil();
115 | $sentence->addCommand("/ip/address/set");
116 | foreach ($param as $name => $value) {
117 | $sentence->setAttribute($name, $value);
118 | }
119 | $sentence->where(".id", "=", $id);
120 | $this->talker->send($sentence);
121 | return "Sucsess";
122 | }
123 |
124 | /**
125 | * This method is used to display one ip address
126 | * in detail based on the id
127 | * @param type $id not string
128 | * @return type array
129 | *
130 | */
131 | public function detail_address($id) {
132 | $sentence = new SentenceUtil();
133 | $sentence->fromCommand("/ip/address/print");
134 | $sentence->where(".id", "=", $id);
135 | $this->talker->send($sentence);
136 | $rs = $this->talker->getResult();
137 | $i = 0;
138 | if ($i < $rs->size()) {
139 | return $rs->getResultArray();
140 | } else {
141 | return "No Ip Address With This id = " . $id;
142 | }
143 | }
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/DHCPClient.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | * @property talker $talker
16 | */
17 | class DHCPClient {
18 |
19 | /**
20 | *
21 | * @var type
22 | */
23 | private $talker;
24 |
25 | function __construct(Talker $talker) {
26 | $this->talker = $talker;
27 | }
28 |
29 | /**
30 | * This method is used to add dhcp client
31 | * @param type $param array
32 | * @return type array
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/ip/dhcp-client/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to disable dhcp client by id
46 | * @param type $id string
47 | * @return type array
48 | */
49 | public function disable($id) {
50 | $sentence = new SentenceUtil();
51 | $sentence->addCommand("/ip/dhcp-client/disable");
52 | $sentence->where(".id", "=", $id);
53 | $this->talker->send($sentence);
54 | return "Sucsess";
55 | }
56 |
57 | /**
58 | * This method is used to enable dhcp client by id
59 | * @param type $id string
60 | * @return type array
61 | */
62 | public function enable($id) {
63 | $sentence = new SentenceUtil();
64 | $sentence->addCommand("/ip/dhcp-client/enable");
65 | $sentence->where(".id", "=", $id);
66 | $this->talker->send($sentence);
67 | return "Sucsess";
68 | }
69 |
70 | /**
71 | * This method is used to renew dhcp client by id
72 | * @param type $id string
73 | * @return type array
74 | */
75 | public function renew_dhcp_client($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/dhcp-client/renew");
78 | $sentence->where(".id", "=", $id);
79 | $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to release dhcp client by id
85 | * @param type $id string
86 | * @return type array
87 | */
88 | public function release_dhcp_client($id) {
89 | $sentence = new SentenceUtil();
90 | $sentence->addCommand("/ip/dhcp-client/release");
91 | $sentence->where(".id", "=", $id);
92 | $this->talker->send($sentence);
93 | return "Sucsess";
94 | }
95 |
96 | /**
97 | * This method is used to set or edit dhcp client by id
98 | * @param type $param array
99 | * @param type $id string
100 | * @return type array
101 | */
102 | public function set_dhcp_client($param, $id) {
103 | $sentence = new SentenceUtil();
104 | $sentence->addCommand("/ip/dhcp-client/set");
105 | foreach ($param as $name => $value) {
106 | $sentence->setAttribute($name, $value);
107 | }
108 | $sentence->where(".id", "=", $id);
109 | $this->talker->send($sentence);
110 | return "Sucsess";
111 | }
112 |
113 | /**
114 | * This method is used to remove dhcp client by id
115 | * @param type $id string
116 | * @return type array
117 | */
118 | public function delete_dhcp_client($id) {
119 | $sentence = new SentenceUtil();
120 | $sentence->addCommand("/ip/dhcp-client/remove");
121 | $sentence->where(".id", "=", $id);
122 | $enable = $this->talker->send($sentence);
123 | return "Sucsess";
124 | }
125 |
126 | /**
127 | * This method is used to display all dhcp client
128 | * @return type array
129 | */
130 | public function getAll() {
131 | $sentence = new SentenceUtil();
132 | $sentence->fromCommand("/ip/dhcp-client/getall");
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Ip Dhcp-Client To Set, Please Your Add Ip Dhcp-Client";
140 | }
141 | }
142 |
143 | /**
144 | * This method is used to display one ip dhcp client
145 | * in detail based on the id
146 | * @param type $id string
147 | * @return type array
148 | */
149 | public function detail($id) {
150 | $sentence = new SentenceUtil();
151 | $sentence->fromCommand("/ip/dhcp-client/print");
152 | $sentence->where(".id", "=", $id);
153 | $this->talker->send($sentence);
154 | $rs = $this->talker->getResult();
155 | $i = 0;
156 | if ($i < $rs->size()) {
157 | return $rs->getResultArray();
158 | } else {
159 | return "No Ip Dhcp-Client With This id = " . $id;
160 | }
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/DHCPRelay.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class DHCPRelay {
17 |
18 | /**
19 | *
20 | * @var \MikrotikAPI\Talker\Talker
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to ip add dhcp relay
30 | * @param type $param array
31 | * @return type array
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/dhcp-relay/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to disable ip dhcp relay by id
45 | * @param type $id string
46 | * @return type array
47 | */
48 | public function disable($id) {
49 | $sentence = new SentenceUtil();
50 | $sentence->addCommand("/ip/dhcp-relay/disable");
51 | $sentence->where(".id", "=", $id);
52 | $this->talker->send($sentence);
53 | return "Sucsess";
54 | }
55 |
56 | /**
57 | * This method is used to enable ip dhcp relay by id
58 | * @param type $id string
59 | * @return type array
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/dhcp-relay/enable");
64 | $sentence->where(".id", "=", $id);
65 | $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to set or edit ip dhcp relay by id
71 | * @param type $param array
72 | * @param type $id string
73 | * @return type array
74 | */
75 | public function set($param, $id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/dhcp-relay/set");
78 | foreach ($param as $name => $value) {
79 | $sentence->setAttribute($name, $value);
80 | }
81 | $sentence->where(".id", "=", $id);
82 | $this->talker->send($sentence);
83 | return "Sucsess";
84 | }
85 |
86 | /**
87 | * This method is used to remove ip dhcp relay by id
88 | * @param type $id string
89 | * @return type array
90 | */
91 | public function delete($id) {
92 | $sentence = new SentenceUtil();
93 | $sentence->addCommand("/ip/dhcp-relay/remove");
94 | $sentence->where(".id", "=", $id);
95 | $this->talker->send($sentence);
96 | return "Sucsess";
97 | }
98 |
99 | /**
100 | * This method is used to display one interface bonding
101 | * in detail based on the id
102 | * @param type $id string
103 | * @return type array
104 | */
105 | public function detail($id) {
106 | $sentence = new SentenceUtil();
107 | $sentence->fromCommand("/ip/dhcp-relay/print");
108 | $sentence->where(".id", "=", $id);
109 | $this->talker->send($sentence);
110 | $rs = $this->talker->getResult();
111 | $i = 0;
112 | if ($i < $rs->size()) {
113 | return $rs->getResultArray();
114 | } else {
115 | return "No Ip Dhcp-Relay With This id = " . $id;
116 | }
117 | }
118 |
119 | /**
120 | * This method is used to display all ip dhcp relay
121 | * @return type array
122 | */
123 | public function getAll() {
124 | $sentence = new SentenceUtil();
125 | $sentence->fromCommand("/ip/dhcp-relay/getall");
126 | $this->talker->send($sentence);
127 | $rs = $this->talker->getResult();
128 | $i = 0;
129 | if ($i < $rs->size()) {
130 | return $rs->getResultArray();
131 | } else {
132 | return "No Ip Dhcp-Relay To Set, Please Your Add Ip Dhcp-Relay";
133 | }
134 | }
135 |
136 | }
137 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/Firewall.php:
--------------------------------------------------------------------------------
1 |
17 | * @copyright Copyright (c) 2011, Virtual Think Team.
18 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
19 | * @category Libraries
20 | */
21 | class Firewall {
22 |
23 | /**
24 | *
25 | * @var type array
26 | */
27 | private $talker;
28 |
29 | function __construct(Talker $talker) {
30 | $this->talker = $talker;
31 | }
32 |
33 | /**
34 | *
35 | * @return \MikrotikAPI\Commands\IP\Firewall\Filter
36 | */
37 | public function filter() {
38 | return new Filter($this->talker);
39 | }
40 |
41 | /**
42 | *
43 | * @return \MikrotikAPI\Commands\IP\Firewall\NAT
44 | */
45 | public function NAT() {
46 | return new NAT($this->talker);
47 | }
48 |
49 | /**
50 | *
51 | * @return \MikrotikAPI\Commands\IP\Firewall\Mangle
52 | */
53 | public function mangle() {
54 | return new Mangle($this->talker);
55 | }
56 |
57 | /**
58 | *
59 | * @return \MikrotikAPI\Commands\IP\Firewall\ServicePort
60 | */
61 | public function servicePort() {
62 | return new ServicePort($this->talker);
63 | }
64 |
65 | /**
66 | *
67 | * @return \MikrotikAPI\Commands\IP\Firewall\Connection
68 | */
69 | public function connection() {
70 | return new Connection($this->talker);
71 | }
72 |
73 | /**
74 | *
75 | * @return \MikrotikAPI\Commands\IP\Firewall\AddressList
76 | */
77 | public function addressList() {
78 | return new AddressList($this->talker);
79 | }
80 |
81 | /**
82 | *
83 | * @return \MikrotikAPI\Commands\IP\Firewall\Layer7Protocol
84 | */
85 | public function layer7Protocol() {
86 | return new Layer7Protocol($this->talker);
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallAddressList.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyrigh Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class FirewallAddressList {
16 |
17 | /**
18 | *
19 | * @var Talker $talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | *
29 | * @param type $param array
30 | * @return type array
31 | * This method is used to add address list
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/firewall/address-list/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to display all firewall filter
45 | * @return type array
46 | *
47 | */
48 | public function getAll() {
49 | $sentence = new SentenceUtil();
50 | $sentence->fromCommand("/ip/firewall/address-list/getall");
51 | $this->talker->send($sentence);
52 | $rs = $this->talker->getResult();
53 | $i = 0;
54 | if ($i < $rs->size()) {
55 | return $rs->getResultArray();
56 | } else {
57 | return "No Ip Firewall Address List To Set, Please Your Add IP Firewall Address List ";
58 | }
59 | }
60 |
61 | /**
62 | * This method is used to enable firewall filter by id
63 | * @param type $id string
64 | * @return type array
65 | *
66 | */
67 | public function enable($id) {
68 | $sentence = new SentenceUtil();
69 | $sentence->addCommand("/ip/firewall/address-list/enable");
70 | $sentence->where(".id", "=", $id);
71 | $this->talker->send($sentence);
72 | return "Sucsess";
73 | }
74 |
75 | /**
76 | * This method is used to disable firewall filter by id
77 | * @param type $id string
78 | * @return type array
79 | *
80 | */
81 | public function disable($id) {
82 | $sentence = new SentenceUtil();
83 | $sentence->addCommand("/ip/firewall/address-list/disable");
84 | $sentence->where(".id", "=", $id);
85 | $this->talker->send($sentence);
86 | return "Sucsess";
87 | }
88 |
89 | /**
90 | * This method is used to remove firewall filter by id
91 | * @param type $id string
92 | * @return type array
93 | *
94 | */
95 | public function delete($id) {
96 | $sentence = new SentenceUtil();
97 | $sentence->addCommand("/ip/firewall/address-list/remove");
98 | $sentence->where(".id", "=", $id);
99 | $this->talker->send($sentence);
100 | return "Sucsess";
101 | }
102 |
103 | /**
104 | * This method is used to change firewall nat based on the id
105 | * @param type $param array
106 | * @param type $id string
107 | * @return type array
108 | *
109 | */
110 | public function set($param, $id) {
111 | $sentence = new SentenceUtil();
112 | $sentence->addCommand("/ip/firewall/address-list/set");
113 | foreach ($param as $name => $value) {
114 | $sentence->setAttribute($name, $value);
115 | }
116 | $sentence->where(".id", "=", $id);
117 | $this->talker->send($sentence);
118 | return "Sucsess";
119 | }
120 |
121 | /**
122 | * This method is used to display one firewall filter
123 | * in detail based on the id
124 | * @param type $id string
125 | * @return type array
126 | *
127 | */
128 | public function detail($id) {
129 | $sentence = new SentenceUtil();
130 | $sentence->fromCommand("/ip/firewall/address-list/print");
131 | $sentence->where(".id", "=", $id);
132 | $this->talker->send($sentence);
133 | $rs = $this->talker->getResult();
134 | $i = 0;
135 | if ($i < $rs->size()) {
136 | return $rs->getResultArray();
137 | } else {
138 | return "No IP Firewall Address List With This id = " . $id;
139 | }
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallConnection.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class FirewallConnection {
16 |
17 | /**
18 | *
19 | * @var Talker $talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method used for get all firewall connection
29 | * @return type array
30 | */
31 | public function getAll() {
32 | $sentence = new SentenceUtil();
33 | $sentence->fromCommand("/ip/firewall/connection/getall");
34 | $this->talker->send($sentence);
35 | $rs = $this->talker->getResult();
36 | $i = 0;
37 | if ($i < $rs->size()) {
38 | return $rs->getResultArray();
39 | } else {
40 | return "No Ip Firewall Connection To Set, Please Your Add Ip Firewall Connection";
41 | }
42 | }
43 |
44 | /**
45 | * This method used for delete firewall connection
46 | * @param type $id string
47 | * @return type array
48 | */
49 | public function delete($id) {
50 | $sentence = new SentenceUtil();
51 | $sentence->addCommand("/ip/firewall/connection/remove");
52 | $sentence->where(".id", "=", $id);
53 | $this->talker->send($sentence);
54 | return "Sucsess";
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallFilter.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class FirewallFilter {
16 |
17 | /**
18 | *
19 | * @var Talker $talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | *
29 | * @param type $param array
30 | * @return type array
31 | * This method is used to add the firewall filter
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/firewall/filter/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to display all firewall filter
45 | * @return type array
46 | *
47 | */
48 | public function getAll() {
49 | $sentence = new SentenceUtil();
50 | $sentence->fromCommand("/ip/firewall/filter/getall");
51 | $this->talker->send($sentence);
52 | $rs = $this->talker->getResult();
53 | $i = 0;
54 | if ($i < $rs->size()) {
55 | return $rs->getResultArray();
56 | } else {
57 | return "No Ip Firewall Filter To Set, Please Your Add Ip Firewall Filter";
58 | }
59 | }
60 |
61 | /**
62 | * This method is used to enable firewall filter by id
63 | * @param type $id string
64 | * @return type array
65 | *
66 | */
67 | public function enable($id) {
68 | $sentence = new SentenceUtil();
69 | $sentence->addCommand("/ip/firewall/filter/enable");
70 | $sentence->where(".id", "=", $id);
71 | $this->talker->send($sentence);
72 | return "Sucsess";
73 | }
74 |
75 | /**
76 | * This method is used to disable firewall filter by id
77 | * @param type $id string
78 | * @return type array
79 | *
80 | */
81 | public function disable($id) {
82 | $sentence = new SentenceUtil();
83 | $sentence->addCommand("/ip/firewall/filter/disable");
84 | $sentence->where(".id", "=", $id);
85 | $this->talker->send($sentence);
86 | return "Sucsess";
87 | }
88 |
89 | /**
90 | * This method is used to remove firewall filter by id
91 | * @param type $id string
92 | * @return type array
93 | *
94 | */
95 | public function delete($id) {
96 | $sentence = new SentenceUtil();
97 | $sentence->addCommand("/ip/firewall/filter/remove");
98 | $sentence->where(".id", "=", $id);
99 | $this->talker->send($sentence);
100 | return "Sucsess";
101 | }
102 |
103 | /**
104 | * This method is used to change firewall nat based on the id
105 | * @param type $param array
106 | * @param type $id string
107 | * @return type array
108 | *
109 | */
110 | public function set($param, $id) {
111 | $sentence = new SentenceUtil();
112 | $sentence->addCommand("/ip/firewall/filter/set");
113 | foreach ($param as $name => $value) {
114 | $sentence->setAttribute($name, $value);
115 | }
116 | $sentence->where(".id", "=", $id);
117 | $this->talker->send($sentence);
118 | return "Sucsess";
119 | }
120 |
121 | /**
122 | * This method is used to display one firewall filter
123 | * in detail based on the id
124 | * @param type $id string
125 | * @return type array
126 | *
127 | */
128 | public function detail($id) {
129 | $sentence = new SentenceUtil();
130 | $sentence->fromCommand("/ip/firewall/filter/print");
131 | $sentence->where(".id", "=", $id);
132 | $this->talker->send($sentence);
133 | $rs = $this->talker->getResult();
134 | $i = 0;
135 | if ($i < $rs->size()) {
136 | return $rs->getResultArray();
137 | } else {
138 | return "No Ip Firewall Filter With This id = " . $id;
139 | }
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallLayer7Protocol.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class FirewallLayer7Protocol {
16 |
17 | /**
18 | *
19 | * @var Talker $talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | *
29 | * @param type $param array
30 | * @return type array
31 | * This method is used to add layer7 protocol
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/firewall/layer7-protocol/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to display all layer7 protocol
45 | * @return type array
46 | *
47 | */
48 | public function getAll() {
49 | $sentence = new SentenceUtil();
50 | $sentence->fromCommand("/ip/firewall/layer7-protocol/getall");
51 | $this->talker->send($sentence);
52 | $rs = $this->talker->getResult();
53 | $i = 0;
54 | if ($i < $rs->size()) {
55 | return $rs->getResultArray();
56 | } else {
57 | return "No Ip Firewall Address List To Set, "
58 | . "Please Your Add IP Firewall Layer7 Protocol ";
59 | }
60 | }
61 |
62 | /**
63 | * This method is used to enable firewall layer7 protocol by id
64 | * @param type $id string
65 | * @return type array
66 | *
67 | */
68 | public function enable($id) {
69 | $sentence = new SentenceUtil();
70 | $sentence->addCommand("/ip/firewall/layer7-protocol/enable");
71 | $sentence->where(".id", "=", $id);
72 | $this->talker->send($sentence);
73 | return "Sucsess";
74 | }
75 |
76 | /**
77 | * This method is used to disable firewall layer7 protocol by id
78 | * @param type $id string
79 | * @return type array
80 | *
81 | */
82 | public function disable($id) {
83 | $sentence = new SentenceUtil();
84 | $sentence->addCommand("/ip/firewall/layer7-protocol/disable");
85 | $sentence->where(".id", "=", $id);
86 | $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to remove firewall layer7 protocol by id
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/ip/firewall/layer7-protocol/remove");
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to change firewall layer7 protocol based on the id
106 | * @param type $param array
107 | * @param type $id string
108 | * @return type array
109 | *
110 | */
111 | public function set($param, $id) {
112 | $sentence = new SentenceUtil();
113 | $sentence->addCommand("/ip/firewall/layer7-protocol/set");
114 | foreach ($param as $name => $value) {
115 | $sentence->setAttribute($name, $value);
116 | }
117 | $sentence->where(".id", "=", $id);
118 | $this->talker->send($sentence);
119 | return "Sucsess";
120 | }
121 |
122 | /**
123 | * This method is used to display one layer7 protocol
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/ip/firewall/layer7-protocol/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No IP Firewall Layer7 Protocol With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallMangle.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | *
15 | */
16 | class FirewallMangle {
17 |
18 | /**
19 | *
20 | * @var Talker $talker
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method used for add new Ip Firewall Mangle
30 | * @param type $param array
31 | * @return type array
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/firewall/mangle/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method used for disable Ip Firewall Mangle
45 | * @param type $id string
46 | * @return type array
47 | */
48 | public function disable($id) {
49 | $sentence = new SentenceUtil();
50 | $sentence->addCommand("/ip/firewall/mangle/disable");
51 | $sentence->where(".id", "=", $id);
52 | $this->talker->send($sentence);
53 | return "Sucsess";
54 | }
55 |
56 | /**
57 | * This method used for enable Ip Firewall Mangle
58 | * @param type $id string
59 | * @return type array
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/firewall/mangle/enable");
64 | $sentence->where(".id", "=", $id);
65 | $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method used for delete Ip Firewall Mangle
71 | * @param type $id string
72 | * @return type array
73 | */
74 | public function delete($id) {
75 | $sentence = new SentenceUtil();
76 | $sentence->addCommand("/ip/firewall/mangle/remove");
77 | $sentence->where(".id", "=", $id);
78 | $this->talker->send($sentence);
79 | return "Sucsess";
80 | }
81 |
82 | /**
83 | * This method used for detail Ip Firewall Mangle
84 | * @param type $id string
85 | * @return type array
86 | */
87 | public function detail($id) {
88 | $sentence = new SentenceUtil();
89 | $sentence->fromCommand("/ip/firewall/mangle/print");
90 | $sentence->where(".id", "=", $id);
91 | $this->talker->send($sentence);
92 | $rs = $this->talker->getResult();
93 | $i = 0;
94 | if ($i < $rs->size()) {
95 | return $rs->getResultArray();
96 | } else {
97 | return "No Ip Firewall Mangle With This id = " . $id;
98 | }
99 | }
100 |
101 | /**
102 | * This method used for set or edit Ip Firewall Mangle
103 | * @param type $param array
104 | * @param type $id string
105 | * @return type array
106 | */
107 | public function set($param, $id) {
108 | $sentence = new SentenceUtil();
109 | $sentence->addCommand("/ip/firewall/mangle/set");
110 | foreach ($param as $name => $value) {
111 | $sentence->setAttribute($name, $value);
112 | }
113 | $sentence->where(".id", "=", $id);
114 | $this->talker->send($sentence);
115 | return "Sucsess";
116 | }
117 |
118 | /**
119 | * This method used for get all Ip Firewall Mangle
120 | * @return type array
121 | */
122 | public function getAll() {
123 | $sentence = new SentenceUtil();
124 | $sentence->fromCommand("/ip/firewall/mangle/getall");
125 | $this->talker->send($sentence);
126 | $rs = $this->talker->getResult();
127 | $i = 0;
128 | if ($i < $rs->size()) {
129 | return $rs->getResultArray();
130 | } else {
131 | return "No Ip Firewall Mangle To Set, Please Your Add Ip Firewall Mangle";
132 | }
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallNAT.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | *
15 | */
16 | class FirewallNAT {
17 |
18 | /**
19 | *
20 | * @var Talker $talker
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add the firewall nat
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/ip/firewall/nat/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to disable firewall nat by id
46 | * @param type $id string
47 | * @return type array
48 | *
49 | */
50 | public function disable($id) {
51 | $sentence = new SentenceUtil();
52 | $sentence->addCommand("/ip/firewall/nat/disable");
53 | $sentence->where(".id", "=", $id);
54 | $this->talker->send($sentence);
55 | return "Sucsess";
56 | }
57 |
58 | /**
59 | * This method is used to enable firewall nat by id
60 | * @param type $id string
61 | * @return type array
62 | *
63 | */
64 | public function enable($id) {
65 | $sentence = new SentenceUtil();
66 | $sentence->addCommand("/ip/firewall/nat/enable");
67 | $sentence->where(".id", "=", $id);
68 | $this->talker->send($sentence);
69 | return "Sucsess";
70 | }
71 |
72 | /**
73 | * This method is used to change firewall nat based on the id
74 | * @param type $param array
75 | * @param type $id string
76 | * @return type array
77 | *
78 | */
79 | public function set($param, $id) {
80 | $sentence = new SentenceUtil();
81 | $sentence->addCommand("/ip/firewall/nat/set");
82 | foreach ($param as $name => $value) {
83 | $sentence->setAttribute($name, $value);
84 | }
85 | $sentence->where(".id", "=", $id);
86 | $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to remove firewall nat
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/ip/firewall/nat/remove");
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to display all firewall nat
106 | * @return type array
107 | *
108 | */
109 | public function getAll() {
110 | $sentence = new SentenceUtil();
111 | $sentence->fromCommand("/ip/firewall/nat/getall");
112 | $this->talker->send($sentence);
113 | $rs = $this->talker->getResult();
114 | $i = 0;
115 | if ($i < $rs->size()) {
116 | return $rs->getResultArray();
117 | } else {
118 | return "No Ip Firewall NAT To Set, Please Your Add Ip Firewall NAT";
119 | }
120 | }
121 |
122 | /**
123 | * This method is used to display one firewall nat
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/ip/firewall/nat/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Ip Firewall NAT With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Firewall/FirewallServicePort.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class FirewallServicePort {
16 |
17 | /**
18 | *
19 | * @var Talker $talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method used for get all Ip Firewall Service Port
29 | * @return array
30 | */
31 | public function getAll() {
32 | $sentence = new SentenceUtil();
33 | $sentence->fromCommand("/ip/firewall/service-port/getall");
34 | $this->talker->send($sentence);
35 | $rs = $this->talker->getResult();
36 | $i = 0;
37 | if ($i < $rs->size()) {
38 | return $rs->getResultArray();
39 | } else {
40 | return "No Ip Firewall service-port To Set, Please Your Add Ip Firewall service-port";
41 | }
42 | }
43 |
44 | /**
45 | * This method used for disable Ip Firewall Service Port
46 | * @param type $id string
47 | * @return type array
48 | */
49 | public function disable($id) {
50 | $sentence = new SentenceUtil();
51 | $sentence->addCommand("/ip/firewall/service-port/disable");
52 | $sentence->where(".id", "=", $id);
53 | $this->talker->send($sentence);
54 | return "Sucsess";
55 | }
56 |
57 | /**
58 | * This method used for enable Ip Firewall Service Port
59 | * @param type $id string
60 | * @return type array
61 | */
62 | public function enable($id) {
63 | $sentence = new SentenceUtil();
64 | $sentence->addCommand("/ip/firewall/service-port/enable");
65 | $sentence->where(".id", "=", $id);
66 | $this->talker->send($sentence);
67 | return "Sucsess";
68 | }
69 |
70 | /**
71 | *
72 | * @param type $id string
73 | * @return type array
74 | *
75 | */
76 | public function detail($id) {
77 | $sentence = new SentenceUtil();
78 | $sentence->fromCommand("/ip/firewall/service-port/print");
79 | $sentence->where(".id", "=", $id);
80 | $this->talker->send($sentence);
81 | $rs = $this->talker->getResult();
82 | $i = 0;
83 | if ($i < $rs->size()) {
84 | return $rs->getResultArray();
85 | } else {
86 | return "No Ip Firewall Service-Port With This id = " . $id;
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/Hotspot.php:
--------------------------------------------------------------------------------
1 |
18 | * @copyright Copyright (c) 2011, Virtual Think Team.
19 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
20 | * @category Libraries
21 | */
22 | class Hotspot {
23 |
24 | /**
25 | *
26 | * @var Talker
27 | */
28 | private $talker;
29 |
30 | function __construct(Talker $talker) {
31 | $this->talker = $talker;
32 | }
33 |
34 | /**
35 | *
36 | * @return \MikrotikAPI\Commands\IP\Hotspot\Server
37 | */
38 | public function server() {
39 | return new Server($this->talker);
40 | }
41 |
42 | /**
43 | *
44 | * @return \MikrotikAPI\Commands\IP\Hotspot\ServerProfiles
45 | */
46 | public function serverProfiles() {
47 | return new ServerProfiles($this->talker);
48 | }
49 |
50 | /**
51 | *
52 | * @return \MikrotikAPI\Commands\IP\Hotspot\Users
53 | */
54 | public function users() {
55 | return new Users($this->talker);
56 | }
57 |
58 | /**
59 | *
60 | * @return \MikrotikAPI\Commands\IP\Hotspot\UserProfile
61 | */
62 | public function userProfiles() {
63 | return new UserProfile($this->talker);
64 | }
65 |
66 | /**
67 | *
68 | * @return \MikrotikAPI\Commands\IP\Hotspot\Active
69 | */
70 | public function active() {
71 | return new Active($this->talker);
72 | }
73 |
74 | /**
75 | *
76 | * @return \MikrotikAPI\Commands\IP\Hotspot\Hosts
77 | */
78 | public function hosts() {
79 | return new Hosts($this->talker);
80 | }
81 |
82 | /**
83 | *
84 | * @return \MikrotikAPI\Commands\IP\Hotspot\IPBindings
85 | */
86 | public function IPBinding() {
87 | return new IPBindings($this->talker);
88 | }
89 |
90 | /**
91 | *
92 | * @return \MikrotikAPI\Commands\IP\Hotspot\Cookie
93 | */
94 | public function cookie() {
95 | return new Cookie($this->talker);
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotActive.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class HotspotActive {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add active
29 | * @return array
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/active/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot by id
43 | * @param string $id
44 | * @return array
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/active/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to display all hotspot
57 | * @return type array
58 | *
59 | */
60 | public function getAll() {
61 | $sentence = new SentenceUtil();
62 | $sentence->fromCommand("/ip/hotspot/active/getall");
63 | $this->talker->send($sentence);
64 | $rs = $this->talker->getResult();
65 | $i = 0;
66 | if ($i < $rs->size()) {
67 | return $rs->getResultArray();
68 | } else {
69 | return "No IP Hotspot Active To Set, Please Your Add IP Hotspot Active";
70 | }
71 | }
72 |
73 | /**
74 | * This method is used to display hotspot
75 | * in detail based on the id
76 | * @param string $id
77 | * @return type array
78 | *
79 | */
80 | public function detail($id) {
81 | $sentence = new SentenceUtil();
82 | $sentence->fromCommand("/ip/hotspot/active/print");
83 | $sentence->where(".id", "=", $id);
84 | $this->talker->send($sentence);
85 | $rs = $this->talker->getResult();
86 | $i = 0;
87 | if ($i < $rs->size()) {
88 | return $rs->getResultArray();
89 | } else {
90 | return "No IP Hotspot Active With This id = " . $id;
91 | }
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotCookies.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category name
14 | */
15 | class HotspotCookie {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method is used to delete hotspot cookie by id
29 | * @param string $id
30 | * @return string
31 | *
32 | */
33 | public function delete($id) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/hotspot/cookie/remove");
36 | $sentence->where(".id", "=", $id);
37 | $enable = $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to display all cookie on hotspot
43 | * @return array or string
44 | *
45 | */
46 | public function getAll() {
47 | $sentence = new SentenceUtil();
48 | $sentence->fromCommand("/ip/hotspot/cookie/getall");
49 | $this->talker->send($sentence);
50 | $rs = $this->talker->getResult();
51 | $i = 0;
52 | if ($i < $rs->size()) {
53 | return $rs->getResultArray();
54 | } else {
55 | return "No IP Hotspot Cookie To Set, Please Your Add IP Hotspot Cookie";
56 | }
57 | }
58 |
59 | /**
60 | * This method is used to display hotspot cookie
61 | * in detail based on the id
62 | * @param string $id
63 | * @return array
64 | *
65 | */
66 | public function detail($id) {
67 | $sentence = new SentenceUtil();
68 | $sentence->fromCommand("/ip/hotspot/cookie/print");
69 | $sentence->where(".id", "=", $id);
70 | $this->talker->send($sentence);
71 | $rs = $this->talker->getResult();
72 | $i = 0;
73 | if ($i < $rs->size()) {
74 | return $rs->getResultArray();
75 | } else {
76 | return "No IP Hotspot Cookie With This id = " . $id;
77 | }
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotHosts.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class HotspotHosts {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method is used to delete hotspot by id
29 | * @param string $id
30 | * @return array
31 | *
32 | */
33 | public function delete($id) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/hotspot/host/remove");
36 | $sentence->where(".id", "=", $id);
37 | $enable = $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to display all hotspot
43 | * @return type array
44 | *
45 | */
46 | public function getAll() {
47 | $sentence = new SentenceUtil();
48 | $sentence->fromCommand("/ip/hotspot/host/getall");
49 | $this->talker->send($sentence);
50 | $rs = $this->talker->getResult();
51 | $i = 0;
52 | if ($i < $rs->size()) {
53 | return $rs->getResultArray();
54 | } else {
55 | return "No IP Hotspot Host To Set, Please Your Add IP Hotspot Host";
56 | }
57 | }
58 |
59 | /**
60 | * This method is used to display hotspot host
61 | * in detail based on the id
62 | * @param string $id
63 | * @return type array
64 | *
65 | */
66 | public function detail($id) {
67 | $sentence = new SentenceUtil();
68 | $sentence->fromCommand("/ip/hotspot/host/print");
69 | $sentence->where(".id", "=", $id);
70 | $this->talker->send($sentence);
71 | $rs = $this->talker->getResult();
72 | $i = 0;
73 | if ($i < $rs->size()) {
74 | return $rs->getResultArray();
75 | } else {
76 | return "No IP Hotspot Host With This id = " . $id;
77 | }
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotIPBindings.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category name
14 | */
15 | class HotspotIPBindings {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add hotspot ip binding
29 | * @return string
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/ip-binding/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot ip binding by id
43 | * @param string $id
44 | * @return string
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/ip-binding/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to enable hotspot ip binding by id
57 | * @param type $id string
58 | * @return string
59 | *
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/hotspot/ip-binding/enable");
64 | $sentence->where(".id", "=", $id);
65 | $enable = $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to disable hotspot ip binding by id
71 | * @param string $id
72 | * @return string
73 | *
74 | */
75 | public function disable($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/hotspot/ip-binding/disable");
78 | $sentence->where(".id", "=", $id);
79 | $disable = $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to set or edit by id
85 | * @param array $param
86 | * @param string $id
87 | * @return string
88 | *
89 | */
90 | public function set($param, $id) {
91 | $sentence = new SentenceUtil();
92 | $sentence->addCommand("/ip/hotspot/ip-binding/set");
93 | foreach ($param as $name => $value) {
94 | $sentence->setAttribute($name, $value);
95 | }
96 | $sentence->where(".id", "=", $id);
97 | $this->talker->send($sentence);
98 | return "Sucsess";
99 | }
100 |
101 | /**
102 | * This method is used to display all ip binding on hotspot
103 | * @return array or string
104 | *
105 | */
106 | public function getAll() {
107 | $sentence = new SentenceUtil();
108 | $sentence->fromCommand("/ip/hotspot/ip-binding/getall");
109 | $this->talker->send($sentence);
110 | $rs = $this->talker->getResult();
111 | $i = 0;
112 | if ($i < $rs->size()) {
113 | return $rs->getResultArray();
114 | } else {
115 | return "No IP Hotspot IP Binding To Set, Please Your Add IP Hotspot IP Binding";
116 | }
117 | }
118 |
119 | /**
120 | * This method is used to display hotspot ip binding
121 | * in detail based on the id
122 | * @param string $id
123 | * @return array
124 | *
125 | */
126 | public function detail($id) {
127 | $sentence = new SentenceUtil();
128 | $sentence->fromCommand("/ip/hotspot/ip-binding/print");
129 | $sentence->where(".id", "=", $id);
130 | $this->talker->send($sentence);
131 | $rs = $this->talker->getResult();
132 | $i = 0;
133 | if ($i < $rs->size()) {
134 | return $rs->getResultArray();
135 | } else {
136 | return "No IP Hotspot IP Binding With This id = " . $id;
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotServer.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class HotspotServer {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add hotspot
29 | * @return type array
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot by id
43 | * @param type $id string
44 | * @return type array
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to enable hotspot by id
57 | * @param type $id string
58 | * @return type array
59 | *
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/hotspot/enable");
64 | $sentence->where(".id", "=", $id);
65 | $enable = $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to disable hotspot by id
71 | * @param type $id string
72 | * @return type array
73 | *
74 | */
75 | public function disable($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/hotspot/disable");
78 | $sentence->where(".id", "=", $id);
79 | $disable = $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to set or edit by id
85 | * @param type $param array
86 | * @param type $id string
87 | * @return type array
88 | *
89 | */
90 | public function set($param, $id) {
91 | $sentence = new SentenceUtil();
92 | $sentence->addCommand("/ip/hotspot/set");
93 | foreach ($param as $name => $value) {
94 | $sentence->setAttribute($name, $value);
95 | }
96 | $sentence->where(".id", "=", $id);
97 | $this->talker->send($sentence);
98 | return "Sucsess";
99 | }
100 |
101 | /**
102 | * This method is used to display all hotspot
103 | * @return type array
104 | *
105 | */
106 | public function getAll() {
107 | $sentence = new SentenceUtil();
108 | $sentence->fromCommand("/ip/hotspot/getall");
109 | $this->talker->send($sentence);
110 | $rs = $this->talker->getResult();
111 | $i = 0;
112 | if ($i < $rs->size()) {
113 | return $rs->getResultArray();
114 | } else {
115 | return "No IP Hotspot To Set, Please Your Add IP Hotspot";
116 | }
117 | }
118 |
119 | /**
120 | * This method is used to display hotspot
121 | * in detail based on the id
122 | * @param type $id string
123 | * @return type array
124 | *
125 | */
126 | public function detail($id) {
127 | $sentence = new SentenceUtil();
128 | $sentence->fromCommand("/ip/hotspot/print");
129 | $sentence->where(".id", "=", $id);
130 | $this->talker->send($sentence);
131 | $rs = $this->talker->getResult();
132 | $i = 0;
133 | if ($i < $rs->size()) {
134 | return $rs->getResultArray();
135 | } else {
136 | return "No IP Hotspot With This id = " . $id;
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotServerProfiles.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class HotspotServerProfiles {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add hotspot profile
29 | * @return type array
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/profile/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot profile by id
43 | * @param type $id string
44 | * @return type array
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/profile/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to enable hotspot profile by id
57 | * @param type $id string
58 | * @return type array
59 | *
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/hotspot/profile/enable");
64 | $sentence->where(".id", "=", $id);
65 | $enable = $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to disable hotspot profile by id
71 | * @param type $id string
72 | * @return type array
73 | *
74 | */
75 | public function disable($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/hotspot/profile/disable");
78 | $sentence->where(".id", "=", $id);
79 | $disable = $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to set or edit by id
85 | * @param type $param array
86 | * @param type $id string
87 | * @return type array
88 | *
89 | */
90 | public function set($param, $id) {
91 | $sentence = new SentenceUtil();
92 | $sentence->addCommand("/ip/hotspot/profile/set");
93 | foreach ($param as $name => $value) {
94 | $sentence->setAttribute($name, $value);
95 | }
96 | $sentence->where(".id", "=", $id);
97 | $this->talker->send($sentence);
98 | return "Sucsess";
99 | }
100 |
101 | /**
102 | * This method is used to display all hotspot profile
103 | * @return type array
104 | *
105 | */
106 | public function getAll() {
107 | $sentence = new SentenceUtil();
108 | $sentence->fromCommand("/ip/hotspot/profile/getall");
109 | $this->talker->send($sentence);
110 | $rs = $this->talker->getResult();
111 | $i = 0;
112 | if ($i < $rs->size()) {
113 | return $rs->getResultArray();
114 | } else {
115 | return "No IP Hotspot Profile To Set, Please Your Add IP Hotspot Profile";
116 | }
117 | }
118 |
119 | /**
120 | * This method is used to display hotspot
121 | * in detail based on the id
122 | * @param type $id string
123 | * @return type array
124 | *
125 | */
126 | public function detail($id) {
127 | $sentence = new SentenceUtil();
128 | $sentence->fromCommand("/ip/hotspot/profile/print");
129 | $sentence->where(".id", "=", $id);
130 | $this->talker->send($sentence);
131 | $rs = $this->talker->getResult();
132 | $i = 0;
133 | if ($i < $rs->size()) {
134 | return $rs->getResultArray();
135 | } else {
136 | return "No IP Hotspot Profile With This id = " . $id;
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotUserProfiles.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category name
14 | */
15 | class HotspotUserProfile {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add hotspot user p
29 | * @return type array
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/user/profile/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot user profile by id
43 | * @param type $id string
44 | * @return type array
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/user/profile/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to enable hotspot user profile by id
57 | * @param type $id string
58 | * @return type array
59 | *
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/hotspot/user/profile/enable");
64 | $sentence->where(".id", "=", $id);
65 | $enable = $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to disable hotspot user profile by id
71 | * @param type $id string
72 | * @return type array
73 | *
74 | */
75 | public function disable($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/hotspot/user/profile/disable");
78 | $sentence->where(".id", "=", $id);
79 | $disable = $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to set or edit by id
85 | * @param type $param array
86 | * @param type $id string
87 | * @return type array
88 | *
89 | */
90 | public function set($param, $id) {
91 | $sentence = new SentenceUtil();
92 | $sentence->addCommand("/ip/hotspot/user/profile/set");
93 | foreach ($param as $name => $value) {
94 | $sentence->setAttribute($name, $value);
95 | }
96 | $sentence->where(".id", "=", $id);
97 | $this->talker->send($sentence);
98 | return "Sucsess";
99 | }
100 |
101 | /**
102 | * This method is used to display all hotspot user profile
103 | * @return type array
104 | *
105 | */
106 | public function getAll() {
107 | $sentence = new SentenceUtil();
108 | $sentence->fromCommand("/ip/hotspot/user/profile/getall");
109 | $this->talker->send($sentence);
110 | $rs = $this->talker->getResult();
111 | $i = 0;
112 | if ($i < $rs->size()) {
113 | return $rs->getResultArray();
114 | } else {
115 | return "No IP Hotspot User Profile To Set, Please Your Add IP Hotspot User Profile";
116 | }
117 | }
118 |
119 | /**
120 | * This method is used to display hotspot user profile
121 | * in detail based on the id
122 | * @param string $id
123 | * @return array
124 | *
125 | */
126 | public function detail($id) {
127 | $sentence = new SentenceUtil();
128 | $sentence->fromCommand("/ip/hotspot/user/profile/print");
129 | $sentence->where(".id", "=", $id);
130 | $this->talker->send($sentence);
131 | $rs = $this->talker->getResult();
132 | $i = 0;
133 | if ($i < $rs->size()) {
134 | return $rs->getResultArray();
135 | } else {
136 | return "No IP Hotspot User Profile With This id = " . $id;
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Hotspot/HotspotUsers.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category name
14 | */
15 | class HotspotUsers {
16 |
17 | /**
18 | *
19 | * @var Talker
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This function is used to add hotspot
29 | * @return type array
30 | */
31 | public function add($param) {
32 | $sentence = new SentenceUtil();
33 | $sentence->addCommand("/ip/hotspot/user/add");
34 | foreach ($param as $name => $value) {
35 | $sentence->setAttribute($name, $value);
36 | }
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to delete hotspot by id
43 | * @param type $id string
44 | * @return type array
45 | *
46 | */
47 | public function delete($id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/hotspot/user/remove");
50 | $sentence->where(".id", "=", $id);
51 | $enable = $this->talker->send($sentence);
52 | return "Sucsess";
53 | }
54 |
55 | /**
56 | * This method is used to enable hotspot by id
57 | * @param type $id string
58 | * @return type array
59 | *
60 | */
61 | public function enable($id) {
62 | $sentence = new SentenceUtil();
63 | $sentence->addCommand("/ip/hotspot/user/enable");
64 | $sentence->where(".id", "=", $id);
65 | $enable = $this->talker->send($sentence);
66 | return "Sucsess";
67 | }
68 |
69 | /**
70 | * This method is used to disable hotspot by id
71 | * @param type $id string
72 | * @return type array
73 | *
74 | */
75 | public function disable($id) {
76 | $sentence = new SentenceUtil();
77 | $sentence->addCommand("/ip/hotspot/user/disable");
78 | $sentence->where(".id", "=", $id);
79 | $disable = $this->talker->send($sentence);
80 | return "Sucsess";
81 | }
82 |
83 | /**
84 | * This method is used to reset uptime and trafic counters for hotspot by id
85 | * @param type $id string
86 | * @return type array
87 | *
88 | */
89 | public function resetCounter($id) {
90 | $sentence = new SentenceUtil();
91 | $sentence->addCommand("/ip/hotspot/user/reset-counter");
92 | $sentence->where(".id", "=", $id);
93 | $disable = $this->talker->send($sentence);
94 | return "Sucsess";
95 | }
96 |
97 | /**
98 | * This method is used to set or edit by id
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | *
103 | */
104 | public function set($param, $id) {
105 | $sentence = new SentenceUtil();
106 | $sentence->addCommand("/ip/hotspot/user/set");
107 | foreach ($param as $name => $value) {
108 | $sentence->setAttribute($name, $value);
109 | }
110 | $sentence->where(".id", "=", $id);
111 | $this->talker->send($sentence);
112 | return "Sucsess";
113 | }
114 |
115 | /**
116 | * This method is used to display all hotspot
117 | * @return type array
118 | *
119 | */
120 | public function getAll() {
121 | $sentence = new SentenceUtil();
122 | $sentence->fromCommand("/ip/hotspot/user/getall");
123 | $this->talker->send($sentence);
124 | $rs = $this->talker->getResult();
125 | $i = 0;
126 | if ($i < $rs->size()) {
127 | return $rs->getResultArray();
128 | } else {
129 | return "No IP Hotspot User To Set, Please Your Add IP Hotspot User";
130 | }
131 | }
132 |
133 | /**
134 | * This method is used to display hotspot
135 | * in detail based on the id
136 | * @param type $id string
137 | * @return type array
138 | *
139 | */
140 | public function detail($id) {
141 | $sentence = new SentenceUtil();
142 | $sentence->fromCommand("/ip/hotspot/user/print");
143 | $sentence->where(".id", "=", $id);
144 | $this->talker->send($sentence);
145 | $rs = $this->talker->getResult();
146 | $i = 0;
147 | if ($i < $rs->size()) {
148 | return $rs->getResultArray();
149 | } else {
150 | return "No IP Hotspot User With This id = " . $id;
151 | }
152 | }
153 |
154 | }
155 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/IP.php:
--------------------------------------------------------------------------------
1 |
24 | * @copyright Copyright (c) 2011, Virtual Think Team.
25 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
26 | * @category Libraries
27 | */
28 | class IP {
29 |
30 | /**
31 | *
32 | * @var type array
33 | */
34 | private $talker;
35 |
36 | function __construct(Talker $talker) {
37 | $this->talker = $talker;
38 | }
39 |
40 | /**
41 | * This method is use for call instantiate object of class
42 | * \MikrotikAPI\Commands\IP\Address
43 | * @return \MikrotikAPI\Commands\IP\Address
44 | */
45 | public function address() {
46 | return new Address($this->talker);
47 | }
48 |
49 | /**
50 | * This method is use for call instantiate object of class
51 | * \MikrotikAPI\Commands\IP\Hotspot\Hotspot
52 | * @return \MikrotikAPI\Commands\IP\Hotspot\Hotspot
53 | */
54 | public function hotspot() {
55 | return new Hotspot($this->talker);
56 | }
57 |
58 | /**
59 | * This method is use for call instantiate object of class
60 | * \MikrotikAPI\Commands\IP\Pool
61 | * @return \MikrotikAPI\Commands\IP\Pool
62 | */
63 | public function pool() {
64 | return new Pool($this->talker);
65 | }
66 |
67 | /**
68 | * This method is use for call instantiate object of class
69 | * \MikrotikAPI\Commands\IP\DNS
70 | * @return \MikrotikAPI\Commands\IP\DNS
71 | */
72 | public function DNS() {
73 | return new DNS($this->talker);
74 | }
75 |
76 | /**
77 | * This method is use for call instantiate object of class
78 | * \MikrotikAPI\Commands\IP\Firewall\Firewall
79 | * @return \MikrotikAPI\Commands\IP\Firewall\Firewall
80 | */
81 | public function firewall() {
82 | return new Firewall($this->talker);
83 | }
84 |
85 | /**
86 | * This method is use for call instantiate object of class
87 | * \MikrotikAPI\Commands\IP\Accounting
88 | * @return \MikrotikAPI\Commands\IP\Accounting
89 | */
90 | public function accounting() {
91 | return new Accounting($this->talker);
92 | }
93 |
94 | /**
95 | * This method is use for call instantiate object of class
96 | * \MikrotikAPI\Commands\IP\ARP
97 | * @return \MikrotikAPI\Commands\IP\ARP
98 | */
99 | public function ARP() {
100 | return new ARP($this->talker);
101 | }
102 |
103 | /**
104 | * This method is use for call instantiate object of class
105 | * \MikrotikAPI\Commands\IP\DHCPClient
106 | * @return \MikrotikAPI\Commands\IP\DHCPClient
107 | */
108 | public function DHCPClient() {
109 | return new DHCPClient($this->talker);
110 | }
111 |
112 | /**
113 | * This method is use for call instantiate object of class
114 | * \MikrotikAPI\Commands\IP\DHCPRelay
115 | * @return \MikrotikAPI\Commands\IP\DHCPRelay
116 | */
117 | public function DHCPRelay() {
118 | return new DHCPRelay($this->talker);
119 | }
120 |
121 | /**
122 | * This method is use for call instantiate object of class
123 | * \MikrotikAPI\Commands\IP\DHCPServer
124 | * @return \MikrotikAPI\Commands\IP\DHCPServer
125 | */
126 | public function DHCPServer() {
127 | return new DHCPServer($this->talker);
128 | }
129 |
130 | /**
131 | * This method is use for call instantiate object of class
132 | * \MikrotikAPI\Commands\IP\Route
133 | * @return \MikrotikAPI\Commands\IP\Route
134 | */
135 | public function route() {
136 | return new Route($this->talker);
137 | }
138 |
139 | /**
140 | * This method is use for call instantiate object of class
141 | * \MikrotikAPI\Commands\IP\Service
142 | * @return \MikrotikAPI\Commands\IP\Service
143 | */
144 | public function service() {
145 | return new Service($this->talker);
146 | }
147 |
148 | /**
149 | * This method is use for call instantiate object of class
150 | * \MikrotikAPI\Commands\IP\WebProxy
151 | * @return \MikrotikAPI\Commands\IP\WebProxy
152 | */
153 | public function proxy() {
154 | return new WebProxy($this->talker);
155 | }
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Pool.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class Pool {
16 |
17 | /**
18 | *
19 | * @var type array
20 | */
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method is used to add pool
29 | * @param array $param
30 | * @return array
31 | *
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/ip/pool/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to display
45 | * all pool
46 | * @return array or string
47 | */
48 | public function getAll() {
49 | $sentence = new SentenceUtil();
50 | $sentence->fromCommand('/ip/pool/getall');
51 | $this->talker->send($sentence);
52 | $rs = $this->talker->getResult();
53 | $i = 0;
54 | if ($i < $rs->size()) {
55 | return $rs->getResultArray();
56 | } else {
57 | return "No IP Pool To Set, Please Your Add Ip Pool";
58 | }
59 | }
60 |
61 | /**
62 | * This method is used to remove the pool by id
63 | * @param string $id
64 | * @return array
65 | *
66 | */
67 | public function delete($id) {
68 | $sentence = new SentenceUtil();
69 | $sentence->addCommand("/ip/pool/remove");
70 | $sentence->where(".id", "=", $id);
71 | $this->talker->send($sentence);
72 | return "Sucsess";
73 | }
74 |
75 | /**
76 | * This method is used to change pool based on the id
77 | * @param array $param
78 | * @param string $id
79 | * @return array
80 | *
81 | */
82 | public function set($param, $id) {
83 | $sentence = new SentenceUtil();
84 | $sentence->addCommand("/ip/pool/set");
85 | foreach ($param as $name => $value) {
86 | $sentence->setAttribute($name, $value);
87 | }
88 | $sentence->where(".id", "=", $id);
89 | $this->talker->send($sentence);
90 | return "Sucsess";
91 | }
92 |
93 | /**
94 | * This method is used to display one pool
95 | * in detail based on the id
96 | * @param type $id string
97 | * @return type array
98 | *
99 | */
100 | public function detail($id) {
101 | $sentence = new SentenceUtil();
102 | $sentence->fromCommand("/ip/pool/print");
103 | $sentence->where(".id", "=", $id);
104 | $this->talker->send($sentence);
105 | $rs = $this->talker->getResult();
106 | $i = 0;
107 | if ($i < $rs->size()) {
108 | return $rs->getResultArray();
109 | } else {
110 | return "No Ip Pool With This Id = " . $id;
111 | }
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Route.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Route {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to display all ip route
30 | * @return type array
31 | */
32 | public function getAll() {
33 | $sentence = new SentenceUtil();
34 | $sentence->fromCommand("/ip/route/getall");
35 | $this->talker->send($sentence);
36 | $rs = $this->talker->getResult();
37 | $i = 0;
38 | if ($i < $rs->size()) {
39 | return $rs->getResultArray();
40 | } else {
41 | return "No Ip Route To Set, Please Your Add Ip Route";
42 | }
43 | return $this->query('');
44 | }
45 |
46 | /**
47 | * This method is used to add ip route gateway
48 | * @param type $param array
49 | * @return type array
50 | */
51 | public function add($param) {
52 | $sentence = new SentenceUtil();
53 | $sentence->addCommand("/ip/route/add");
54 | foreach ($param as $name => $value) {
55 | $sentence->setAttribute($name, $value);
56 | }
57 | $this->talker->send($sentence);
58 | return "Sucsess";
59 | }
60 |
61 | /**
62 | * Can change or disable only static routes
63 | * @param type $id is not array
64 | *
65 | */
66 | public function disable($id) {
67 | $sentence = new SentenceUtil();
68 | $sentence->addCommand("/ip/route/disable");
69 | $sentence->where(".id", "=", $id);
70 | $this->talker->send($sentence);
71 | return "Sucsess";
72 | }
73 |
74 | /**
75 | * Can change or enable only static routes
76 | * @param type $id string
77 | * @return type array
78 | *
79 | */
80 | public function enable($id) {
81 | $sentence = new SentenceUtil();
82 | $sentence->addCommand("/ip/route/enable");
83 | $sentence->where(".id", "=", $id);
84 | $this->talker->send($sentence);
85 | return "Sucsess";
86 | }
87 |
88 | /**
89 | * Can change or remove only static routes
90 | * @param type $id string
91 | * @return type array
92 | *
93 | */
94 | public function delete($id) {
95 | $sentence = new SentenceUtil();
96 | $sentence->addCommand("/ip/route/remove");
97 | $sentence->where(".id", "=", $id);
98 | $this->talker->send($sentence);
99 | return "Sucsess";
100 | }
101 |
102 | /**
103 | * Can change only static routes
104 | * @param type $param array
105 | * @param type $id string
106 | * @return type array
107 | *
108 | */
109 | public function set($param, $id) {
110 | $sentence = new SentenceUtil();
111 | $sentence->addCommand("/ip/route/set");
112 | foreach ($param as $name => $value) {
113 | $sentence->setAttribute($name, $value);
114 | }
115 | $sentence->where(".id", "=", $id);
116 | $this->talker->send($sentence);
117 | return "Sucsess";
118 | }
119 |
120 | /**
121 | * This method is used to display one ip route
122 | * in detail based on the id
123 | * @param type $id string
124 | * @return type array
125 | *
126 | */
127 | public function detail($id) {
128 | $sentence = new SentenceUtil();
129 | $sentence->fromCommand("/ip/route/print");
130 | $sentence->where(".id", "=", $id);
131 | $this->talker->send($sentence);
132 | $rs = $this->talker->getResult();
133 | $i = 0;
134 | if ($i < $rs->size()) {
135 | return $rs->getResultArray();
136 | } else {
137 | return "No Ip Route With This id = " . $id;
138 | }
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/Service.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Service {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This methode is used to display all ip service
26 | * @return type array
27 | */
28 | public function getAll() {
29 | $sentence = new SentenceUtil();
30 | $sentence->fromCommand("/ip/service/getall");
31 | $this->talker->send($sentence);
32 | $rs = $this->talker->getResult();
33 | $i = 0;
34 | if ($i < $rs->size()) {
35 | return $rs->getResultArray();
36 | } else {
37 | return "No Ip Service To Set, Please Your Add Ip Service";
38 | }
39 | }
40 |
41 | /**
42 | * This methode is used to enable ip service by id
43 | * @param type $id string
44 | * @return type array
45 | */
46 | public function enable($id) {
47 | $sentence = new SentenceUtil();
48 | $sentence->addCommand("/ip/service/enable");
49 | $sentence->where(".id", "=", $id);
50 | $enable = $this->talker->send($sentence);
51 | return "Sucsess";
52 | }
53 |
54 | /**
55 | * This methode is used to disable ip service by id
56 | * @param type $id string
57 | * @return type array
58 | */
59 | public function disable($id) {
60 | $sentence = new SentenceUtil();
61 | $sentence->addCommand("/ip/service/disable");
62 | $sentence->where(".id", "=", $id);
63 | $enable = $this->talker->send($sentence);
64 | return "Sucsess";
65 | }
66 |
67 | /**
68 | * This method is used to display one ip service
69 | * in detail based on the id
70 | * @param type $id string
71 | * @return type array
72 | */
73 | public function detail($id) {
74 | $sentence = new SentenceUtil();
75 | $sentence->fromCommand("/ip/service/print");
76 | $sentence->where(".id", "=", $id);
77 | $this->talker->send($sentence);
78 | $rs = $this->talker->getResult();
79 | $i = 0;
80 | if ($i < $rs->size()) {
81 | return $rs->getResultArray();
82 | } else {
83 | return "No Ip Service With This id = " . $id;
84 | }
85 | }
86 |
87 | /**
88 | *
89 | * @param array $param
90 | * @param string $id
91 | * @return string
92 | */
93 | public function set($param, $id) {
94 | $sentence = new SentenceUtil();
95 | $sentence->addCommand("/ip/service/set");
96 | foreach ($param as $name => $value) {
97 | $sentence->setAttribute($name, $value);
98 | }
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/IP/WebProxy.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 |
16 | class WebProxy {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for get all web proxy config
26 | * @return type array
27 | */
28 | public function getAll() {
29 | $sentence = new SentenceUtil();
30 | $sentence->fromCommand("/ip/proxy/getall");
31 | $this->talker->send($sentence);
32 | $rs = $this->talker->getResult();
33 | $i = 0;
34 | if ($i < $rs->size()) {
35 | return $rs->getResultArray();
36 | } else {
37 | return "No Ip Proxy To Set, Please Your Add Ip Proxy";
38 | }
39 | }
40 |
41 | /**
42 | *
43 | * This method used for set Web Proxy configuration
44 | * @param array $param
45 | * @return array
46 | */
47 | public function set($param) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/ip/proxy/set");
50 | foreach ($param as $name => $value) {
51 | $sentence->setAttribute($name, $value);
52 | }
53 | $this->talker->send($sentence);
54 | return "Sucsess";
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/Ethernet.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Ethernet {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to display all interface
30 | * @return type array
31 | */
32 | public function getAll() {
33 | $sentence = new SentenceUtil();
34 | $sentence->fromCommand("/interface/getall");
35 | $this->talker->send($sentence);
36 | $rs = $this->talker->getResult();
37 | return $rs->getResultArray();
38 | }
39 |
40 | /**
41 | * This method is used to display one interface
42 | * in detail based on the id
43 | * @param type $param array
44 | * @param type $id string
45 | * @return type array
46 | */
47 | public function set($param, $id) {
48 | $sentence = new SentenceUtil();
49 | $sentence->addCommand("/interface/set");
50 | foreach ($param as $name => $value) {
51 | $sentence->setAttribute($name, $value);
52 | }
53 | $sentence->where(".id", "=", $id);
54 | $this->talker->send($sentence);
55 | return "Sucsess";
56 | }
57 |
58 | /**
59 | * This method is used to enable interface by id
60 | * @param type $id string
61 | * @return type array
62 | */
63 | public function enable($id) {
64 | $sentence = new SentenceUtil();
65 | $sentence->addCommand("/interface/enable");
66 | $sentence->where(".id", "=", $id);
67 | $enable = $this->talker->send($sentence);
68 | return "Sucsess";
69 | }
70 |
71 | /**
72 | * This method is used to disable interface by id
73 | * @param type $id string
74 | * @return type array
75 | */
76 | public function disable($id) {
77 | $sentence = new SentenceUtil();
78 | $sentence->addCommand("/interface/disable");
79 | $sentence->where(".id", "=", $id);
80 | $enable = $this->talker->send($sentence);
81 | return "Sucsess";
82 | }
83 |
84 | /**
85 | * This method is used to display one interafce
86 | * in detail based on the id
87 | * @param type $id string
88 | * @return type array
89 | *
90 | */
91 | public function detail($id) {
92 | $sentence = new SentenceUtil();
93 | $sentence->fromCommand("/interface/print");
94 | $sentence->where(".id", "=", $id);
95 | $this->talker->send($sentence);
96 | $rs = $this->talker->getResult();
97 | $i = 0;
98 | if ($i < $rs->size()) {
99 | return $rs->getResultArray();
100 | } else {
101 | return "No Interface Ethernet With This id = " . $id;
102 | }
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/IPTunnel.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class IPTunnel {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add interface ipip
30 | * @param type $param array
31 | * @return type array
32 | */
33 | public function add($param) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/interface/ipip/add");
36 | foreach ($param as $name => $value) {
37 | $sentence->setAttribute($name, $value);
38 | }
39 | $this->talker->send($sentence);
40 | return "Sucsess";
41 | }
42 |
43 | /**
44 | * This method is used to display all interface ipip
45 | * @return type array
46 | */
47 | public function get_all() {
48 | $sentence = new SentenceUtil();
49 | $sentence->fromCommand("/interface/ipip/getall");
50 | $this->talker->send($sentence);
51 | $rs = $this->talker->getResult();
52 | $i = 0;
53 | if ($i < $rs->size()) {
54 | return $rs->getResultArray();
55 | } else {
56 | return "No Interface IPIP To Set, Please Your Add Interface IPIP";
57 | }
58 | }
59 |
60 | /**
61 | * This method is used to enable interface ipip by id
62 | * @param type $id string
63 | * @return type array
64 | */
65 | public function enable($id) {
66 | $sentence = new SentenceUtil();
67 | $sentence->addCommand("/interface/ipip/enable");
68 | $sentence->where(".id", "=", $id);
69 | $enable = $this->talker->send($sentence);
70 | return "Sucsess";
71 | }
72 |
73 | /**
74 | * This method is used to disable interface ipip by id
75 | * @param type $id string
76 | * @return type array
77 | */
78 | public function disable($id) {
79 | $sentence = new SentenceUtil();
80 | $sentence->addCommand("/interface/ipip/disable");
81 | $sentence->where(".id", "=", $id);
82 | $enable = $this->talker->send($sentence);
83 | return "Sucsess";
84 | }
85 |
86 | /**
87 | * This method is used to remove interface ipip
88 | * @param type $id string
89 | * @return type array
90 | */
91 | public function delete($id) {
92 | $sentence = new SentenceUtil();
93 | $sentence->addCommand("/interface/ipip/remove");
94 | $sentence->where(".id", "=", $id);
95 | $enable = $this->talker->send($sentence);
96 | return "Sucsess";
97 | }
98 |
99 | /**
100 | * This method is used to set or edit interface ipip by id
101 | * @param type $param array
102 | * @param type $id string
103 | * @return type
104 | */
105 | public function set($param, $id) {
106 | $sentence = new SentenceUtil();
107 | $sentence->addCommand("/interface/ipip/set");
108 | foreach ($param as $name => $value) {
109 | $sentence->setAttribute($name, $value);
110 | }
111 | $sentence->where(".id", "=", $id);
112 | $this->talker->send($sentence);
113 | return "Sucsess";
114 | }
115 |
116 | /**
117 | * This method is used to display one interface ipip
118 | * in detail based on the id
119 | * @param type $id string
120 | * @return type array
121 | */
122 | public function detail($id) {
123 | $sentence = new SentenceUtil();
124 | $sentence->fromCommand("/interface/ipip/print");
125 | $sentence->where(".id", "=", $id);
126 | $this->talker->send($sentence);
127 | $rs = $this->talker->getResult();
128 | $i = 0;
129 | if ($i < $rs->size()) {
130 | return $rs->getResultArray();
131 | } else {
132 | return "No Interface IPIP With This id = " . $id;
133 | }
134 | }
135 |
136 | }
137 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/Interfaces.php:
--------------------------------------------------------------------------------
1 |
25 | * @copyright Copyright (c) 2011, Virtual Think Team.
26 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
27 | * @category Libraries
28 | */
29 | class Interfaces {
30 |
31 | /**
32 | *
33 | * @var Talker
34 | */
35 | private $talker;
36 |
37 | function __construct(Talker $talker) {
38 | $this->talker = $talker;
39 | }
40 |
41 | /**
42 | * This method is used to call class Ethetrnet
43 | * @return Mapi_Ip
44 | */
45 | public function ethernet() {
46 | return new Ethernet($this->talker);
47 | }
48 |
49 | /**
50 | * This method is used to call class Pppoe_Client
51 | * @return Mapi_Ip
52 | */
53 | public function PPPoEClient() {
54 | return new PPPoEClient($this->talker);
55 | }
56 |
57 | /**
58 | * This method is used to call class Pppoe_Server
59 | * @return Mapi_Ip
60 | */
61 | public function PPPoEServer() {
62 | return new PPPoEServer($this->talker);
63 | }
64 |
65 | /**
66 | * This method is used to call class Eoip
67 | * @return Mapi_Ip
68 | */
69 | public function EoIP() {
70 | return new EoIP($this->talker);
71 | }
72 |
73 | /**
74 | * This method is used to call class Ipip
75 | * @return Mapi_Ip
76 | */
77 | public function IPTunnel() {
78 | return new IPTunnel($this->talker);
79 | }
80 |
81 | /**
82 | * This method is used to call class Vlan
83 | * @return Mapi_Ip
84 | */
85 | public function VLAN() {
86 | return new VLAN($this->talker);
87 | }
88 |
89 | /**
90 | * This method is used to call class Vrrp
91 | * @return Mapi_Ip
92 | */
93 | public function VRRP() {
94 | return new VRRP($this->talker);
95 | }
96 |
97 | /**
98 | * This method is used to call class Bonding
99 | * @return Mapi_Ip
100 | */
101 | public function bonding() {
102 | return new Bonding($this->talker);
103 | }
104 |
105 | /**
106 | * This method for used call class Bridge
107 | * @return Mapi_Ip
108 | */
109 | public function bridge() {
110 | return new Bridge($this->talker);
111 | }
112 |
113 | /**
114 | * This method used call class L2tp_Client
115 | * @return Mapi_Ip
116 | */
117 | public function L2TPClient() {
118 | return new L2TPClient($this->talker);
119 | }
120 |
121 | /**
122 | * This method used call class L2tp_Server
123 | * @return Mapi_Ip
124 | */
125 | public function L2TPServer() {
126 | return new L2TPServer($this->talker);
127 | }
128 |
129 | /**
130 | * This method used call class Ppp_Client
131 | * @return Mapi_Ip
132 | */
133 | public function PPPClient() {
134 | return new PPPClient($this->talker);
135 | }
136 |
137 | /**
138 | * This method used call class Ppp_Server
139 | * @return Mapi_Ip
140 | */
141 | public function PPPServer() {
142 | return new PPPServer($this->talker);
143 | }
144 |
145 | /**
146 | * This method used call class Pptp_Client
147 | * @return Mapi_Ip
148 | */
149 | public function PPTPClient() {
150 | return new PPTPClient($this->talker);
151 | }
152 |
153 | /**
154 | * This method used call class Pptp_Server
155 | * @return Mapi_Ip
156 | */
157 | public function PPTPServer() {
158 | return new PPTPServer($this->talker);
159 | }
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/L2TPClient.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class L2TPClient {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new l2tp client
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/interface/l2tp-client/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable l2tp client
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/interface/l2tp-client/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable l2tp client
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/interface/l2tp-client/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete l2tp client
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/interface/l2tp-client/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail l2tp client
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/interface/l2tp-client/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No Interface L2TP Client With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit l2tp client
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/interface/l2tp-client/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all l2tp client
116 | * @return type array
117 | */
118 | public function getAll() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/interface/l2tp-client/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No Interface L2TP Client To Set, Please Your Add Interface L2TP Client";
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/L2TPServer.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class L2TPServer {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new l2tp server
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/interface/l2tp-server/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable l2tp server
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/interface/l2tp-server/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable l2tp server
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/interface/l2tp-server/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete l2tp server
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/interface/l2tp-server/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail l2tp server
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/interface/l2tp-server/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No Interface L2TP Server With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit l2tp server
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/interface/l2tp-server/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all l2tp server
116 | * @return type array
117 | */
118 | public function getAll() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/interface/l2tp-server/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No Interface L2TP Server To Set, Please Your Add Interface L2TP Server";
128 | }
129 | }
130 |
131 | /**
132 | * This method used for get all l2tp server server
133 | * @return type array
134 | */
135 | public function getAllServer() {
136 | $sentence = new SentenceUtil();
137 | $sentence->fromCommand("/interface/l2tp-server/server/getall");
138 | $this->talker->send($sentence);
139 | $rs = $this->talker->getResult();
140 | $i = 0;
141 | if ($i < $rs->size()) {
142 | return $rs->getResultArray();
143 | } else {
144 | return "No Interface L2TP Server Server To Set, Please Your Add Interface L2TP Server Server";
145 | }
146 | }
147 |
148 | /**
149 | * This method used for set l2tp server server
150 | * @param type $param array
151 | * @return type array
152 | */
153 | public function setServer($param) {
154 | $sentence = new SentenceUtil();
155 | $sentence->addCommand("/interface/l2tp-server/server/set");
156 | foreach ($param as $name => $value) {
157 | $sentence->setAttribute($name, $value);
158 | }
159 | $this->talker->send($sentence);
160 | return "Sucsess";
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/PPPClient.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class PPPClient {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new interface ppp-client
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/interface/ppp-client/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable interface ppp-client
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/interface/ppp-client/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable interface ppp-client
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/interface/ppp-client/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete interface ppp-client
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/interface/ppp-client/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail interface ppp-client
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/interface/ppp-client/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No Interface PPP Client With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit interface ppp-client
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/interface/ppp-client/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all interface ppp-client
116 | * @return type array
117 | */
118 | public function getAll() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/interface/ppp-client/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No Interface PPP Client To Set, Please Your Add Interface PPP Client";
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/PPPServer.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class PPPServer {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new interface ppp-sever
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/interface/ppp-server/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable interface ppp-sever
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/interface/ppp-server/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable interface ppp-sever
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/interface/ppp-server/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete interface ppp-sever
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/interface/ppp-server/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail interface ppp-sever
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/interface/ppp-server/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No Interface PPP Server With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit interface ppp-sever
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/interface/ppp-server/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all interface ppp-sever
116 | * @return array
117 | */
118 | public function getAll() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/interface/ppp-server/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No Interface PPP Server To Set, Please Your Add Interface PPP Server";
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/PPPoEClient.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class PPPoEClient {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add pppoe-client
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/interface/pppoe-client/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to display all pppoe-client
46 | * @return type array
47 | *
48 | */
49 | public function getAll() {
50 | $sentence = new SentenceUtil();
51 | $sentence->fromCommand("/interface/pppoe-client/getall");
52 | $this->talker->send($sentence);
53 | $rs = $this->talker->getResult();
54 | $i = 0;
55 | if ($i < $rs->size()) {
56 | return $rs->getResultArray();
57 | } else {
58 | return "No Interface PPPoE-Client To Set, Please Your Add PPPoE-Client";
59 | }
60 | }
61 |
62 | /**
63 | * This method is used to enable pppoe-client by id
64 | * @param type $id string
65 | * @return type array
66 | *
67 | */
68 | public function enable($id) {
69 | $sentence = new SentenceUtil();
70 | $sentence->addCommand("/interface/pppoe-client/enable");
71 | $sentence->where(".id", "=", $id);
72 | $enable = $this->talker->send($sentence);
73 | return "Sucsess";
74 | }
75 |
76 | /**
77 | * This method is used to disable pppoe-client by id
78 | * @param type $id string
79 | * @return type array
80 | *
81 | */
82 | public function disable($id) {
83 | $sentence = new SentenceUtil();
84 | $sentence->addCommand("/interface/pppoe-client/disable");
85 | $sentence->where(".id", "=", $id);
86 | $enable = $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to delete pppoe-client by id
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/interface/pppoe-client/remove");
99 | $sentence->where(".id", "=", $id);
100 | $enable = $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to set or edit by id
106 | * @param type $param array
107 | * @param type $id string
108 | * @return type array
109 | *
110 | */
111 | public function set($param, $id) {
112 | $sentence = new SentenceUtil();
113 | $sentence->addCommand("/interface/pppoe-client/set");
114 | foreach ($param as $name => $value) {
115 | $sentence->setAttribute($name, $value);
116 | }
117 | $sentence->where(".id", "=", $id);
118 | $this->talker->send($sentence);
119 | return "Sucsess";
120 | }
121 |
122 | /**
123 | * This method is used to display one pppoe-client
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | */
128 | public function detail($id) {
129 | $sentence = new SentenceUtil();
130 | $sentence->fromCommand("/interface/pppoe-client/print");
131 | $sentence->where(".id", "=", $id);
132 | $this->talker->send($sentence);
133 | $rs = $this->talker->getResult();
134 | $i = 0;
135 | if ($i < $rs->size()) {
136 | return $rs->getResultArray();
137 | } else {
138 | return "No Interface PPPoE-Client With This id = " . $id;
139 | }
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/PPPoEServer.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class PPPoEServer {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add pppoe-server
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/interface/pppoe-server/server/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to disable pppoe-server by id
46 | * @param type $id string
47 | * @return type array
48 | *
49 | */
50 | public function disable($id) {
51 | $sentence = new SentenceUtil();
52 | $sentence->addCommand("/interface/pppoe-server/server/disable");
53 | $sentence->where(".id", "=", $id);
54 | $this->talker->send($sentence);
55 | return "Sucsess";
56 | }
57 |
58 | /**
59 | * This method is used to enable pppoe-server by id
60 | * @param type $id string
61 | * @return type array
62 | *
63 | */
64 | public function enable($id) {
65 | $sentence = new SentenceUtil();
66 | $sentence->addCommand("/interface/pppoe-server/server/enable");
67 | $sentence->where(".id", "=", $id);
68 | $this->talker->send($sentence);
69 | return "Sucsess";
70 | }
71 |
72 | /**
73 | * This method is used to set or edit by id
74 | * @param type $param array
75 | * @param type $id string
76 | * @return type array
77 | *
78 | */
79 | public function set($param, $id) {
80 | $sentence = new SentenceUtil();
81 | $sentence->addCommand("/interface/pppoe-server/server/set");
82 | foreach ($param as $name => $value) {
83 | $sentence->setAttribute($name, $value);
84 | }
85 | $sentence->where(".id", "=", $id);
86 | $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to delete pppoe-server by id
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/interface/pppoe-server/server/remove");
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to display all pppoe-server
106 | * @return type array
107 | *
108 | */
109 | public function get_all() {
110 | $sentence = new SentenceUtil();
111 | $sentence->fromCommand("/interface/pppoe-server/server/getall");
112 | $this->talker->send($sentence);
113 | $rs = $this->talker->getResult();
114 | $i = 0;
115 | if ($i < $rs->size()) {
116 | return $rs->getResultArray();
117 | } else {
118 | return "No Interface PPPoE-Server Server To Set, Please Your Add Interface PPPoE-Server Server";
119 | }
120 | }
121 |
122 | /**
123 | * This method is used to display one pppoe-server
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/interface/pppoe-server/server/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Interface PPPoE-Server Server With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/PPTPClient.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class PPTPClient {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new interface pptp-client
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/interface/pptp-client/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable interface pptp-client
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/interface/pptp-client/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable interface pptp-client
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/interface/pptp-client/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete interface pptp-client
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/interface/pptp-client/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail interface pptp-client
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/interface/pptp-client/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No Interface PPTP Client With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit interface pptp-client
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/interface/pptp-client/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all interface pptp-client
116 | * @return type array
117 | */
118 | public function get_all() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/interface/pptp-client/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No Interface PPTP Client To Set, Please Your Add Interface PPTP Client";
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/VLAN.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class VLAN {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add vlan
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/interface/vlan/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to display all vlan
46 | * @return type array
47 | *
48 | */
49 | public function getAll() {
50 | $sentence = new SentenceUtil();
51 | $sentence->fromCommand("/interface/vlan/getall");
52 | $this->talker->send($sentence);
53 | $rs = $this->talker->getResult();
54 | $i = 0;
55 | if ($i < $rs->size()) {
56 | return $rs->getResultArray();
57 | } else {
58 | return "No Interface VLAN To Set, Please Your Add Interface VLAN";
59 | }
60 | }
61 |
62 | /**
63 | * This method is used to enable vlan by id
64 | * @param type $id string
65 | * @return type array
66 | *
67 | */
68 | public function enable($id) {
69 | $sentence = new SentenceUtil();
70 | $sentence->addCommand("/interface/vlan/enable");
71 | $sentence->where(".id", "=", $id);
72 | $enable = $this->talker->send($sentence);
73 | return "Sucsess";
74 | }
75 |
76 | /**
77 | * This method is used to disable vlan by id
78 | * @param type $id string
79 | * @return type array
80 | *
81 | */
82 | public function disable($id) {
83 | $sentence = new SentenceUtil();
84 | $sentence->addCommand("/interface/vlan/disable");
85 | $sentence->where(".id", "=", $id);
86 | $enable = $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to delete vlan by id
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/interface/vlan/remove");
99 | $sentence->where(".id", "=", $id);
100 | $enable = $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to set or edit by id
106 | * @param type $param array
107 | * @param type $id string
108 | * @return type array
109 | *
110 | */
111 | public function set($param, $id) {
112 | $sentence = new SentenceUtil();
113 | $sentence->addCommand("/interface/vlan/set");
114 | foreach ($param as $name => $value) {
115 | $sentence->setAttribute($name, $value);
116 | }
117 | $sentence->where(".id", "=", $id);
118 | $this->talker->send($sentence);
119 | return "Sucsess";
120 | }
121 |
122 | /**
123 | * This method is used to display one vlan
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/interface/vlan/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Interface VLAN With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/Interfaces/VRRP.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class VRRP {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to to add vrrp
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/interface/vrrp/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to display all vrrp
46 | * @return type array
47 | *
48 | */
49 | public function getAll() {
50 | $sentence = new SentenceUtil();
51 | $sentence->fromCommand("/interface/vrrp/getall");
52 | $this->talker->send($sentence);
53 | $rs = $this->talker->getResult();
54 | $i = 0;
55 | if ($i < $rs->size()) {
56 | return $rs->getResultArray();
57 | } else {
58 | return "No Interface VRRP To Set, Please Your Add Interface VRRP";
59 | }
60 | }
61 |
62 | /**
63 | * This method is used to to enable vrrp by id
64 | * @param type $id string
65 | * @return type array
66 | *
67 | */
68 | public function enable($id) {
69 | $sentence = new SentenceUtil();
70 | $sentence->addCommand("/interface/vrrp/enable");
71 | $sentence->where(".id", "=", $id);
72 | $this->talker->send($sentence);
73 | return "Sucsess";
74 | }
75 |
76 | /**
77 | * This method is used to to disable vrrp by id
78 | * @param type $id string
79 | * @return type array
80 | *
81 | */
82 | public function disable($id) {
83 | $sentence = new SentenceUtil();
84 | $sentence->addCommand("/interface/vrrp/disable");
85 | $sentence->where(".id", "=", $id);
86 | $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to to delete vrrp by id
92 | * @param type $id string
93 | * @return type array
94 | *
95 | */
96 | public function delete($id) {
97 | $sentence = new SentenceUtil();
98 | $sentence->addCommand("/interface/vrrp/remove");
99 | $sentence->where(".id", "=", $id);
100 | $this->talker->send($sentence);
101 | return "Sucsess";
102 | }
103 |
104 | /**
105 | * This method is used to change based on the id
106 | * @param type $param array
107 | * @param type $id string
108 | * @return type array
109 | *
110 | */
111 | public function set($param, $id) {
112 | $sentence = new SentenceUtil();
113 | $sentence->addCommand("/interface/vrrp/set");
114 | foreach ($param as $name => $value) {
115 | $sentence->setAttribute($name, $value);
116 | }
117 | $sentence->where(".id", "=", $id);
118 | $this->talker->send($sentence);
119 | return "Sucsess";
120 | }
121 |
122 | /**
123 | * This method is used to display one vrrp
124 | * in detail based on the id
125 | * @param type $id string
126 | * @return type array
127 | *
128 | */
129 | public function detail($id) {
130 | $sentence = new SentenceUtil();
131 | $sentence->fromCommand("/interface/vrrp/print");
132 | $sentence->where(".id", "=", $id);
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | } else {
139 | return "No Interface VRRP With This id = " . $id;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/PPP/AAA.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class AAA {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to display all ppp aaa
30 | * @return type array
31 | */
32 | public function getAll() {
33 | $sentence = new SentenceUtil();
34 | $sentence->fromCommand("/ppp/aaa/getall");
35 | $this->talker->send($sentence);
36 | $rs = $this->talker->getResult();
37 | $i = 0;
38 | if ($i < $rs->size()) {
39 | return $rs->getResultArray();
40 | } else {
41 | return "No PPP AAA To Set, Please Your Add PPP AAA";
42 | }
43 | }
44 |
45 | /**
46 | * This method is used to set ppp aaa
47 | * @param type $use_radius string
48 | * @param type $accounting string
49 | * @param type $interim_update string
50 | * @return type array
51 | */
52 | public function set($use_radius, $accounting, $interim_update) {
53 | $sentence = new SentenceUtil();
54 | $sentence->addCommand("/ppp/aaa/set");
55 | $sentence->setAttribute("use-radius", $use_radius);
56 | $sentence->setAttribute("accounting", $accounting);
57 | $sentence->setAttribute("interim-update", $interim_update);
58 | $this->talker->send($sentence);
59 | return "Sucsess";
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/PPP/Active.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Active {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method is used to display all ppp active
26 | * @return type array
27 | */
28 | public function getAll() {
29 | $sentence = new SentenceUtil();
30 | $sentence->fromCommand("/ppp/active/getall");
31 | $this->talker->send($sentence);
32 | $rs = $this->talker->getResult();
33 | $i = 0;
34 | if ($i < $rs->size()) {
35 | return $rs->getResultArray();
36 | } else {
37 | return "No PPP Active To Set, Please Your Add PPP Active";
38 | }
39 | }
40 |
41 | /**
42 | * This method is used to delete ppp active
43 | * @param type $id string
44 | * @return type array
45 | */
46 | public function delete($id) {
47 | $sentence = new SentenceUtil();
48 | $sentence->addCommand("/ppp/active/remove");
49 | $sentence->where(".id", "=", $id);
50 | $enable = $this->talker->send($sentence);
51 | return "Sucsess";
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/PPP/PPP.php:
--------------------------------------------------------------------------------
1 |
15 | * @copyright Copyright (c) 2011, Virtual Think Team.
16 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
17 | * @category Libraries
18 | */
19 | class PPP {
20 |
21 | private $talker;
22 |
23 | function __construct(Talker $talker) {
24 | $this->talker = $talker;
25 | }
26 |
27 | /**
28 | * This method for call class Profile
29 | * @return Object of Profile class
30 | */
31 | public function profile() {
32 | return new Profile($this->talker);
33 | }
34 |
35 | /**
36 | * This method for call class Secret
37 | * @return Object of Secret
38 | */
39 | public function secret() {
40 | return new Secret($this->talker);
41 | }
42 |
43 | /**
44 | * This method for call class Aaa
45 | * @access public
46 | * @return object of Aaa class
47 | */
48 | public function AAA() {
49 | return new AAA($this->talker);
50 | }
51 |
52 | /**
53 | * This method for call class Active
54 | * @return Object of Active class
55 | */
56 | public function active() {
57 | return new Active($this->talker);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/PPP/Profile.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Profile {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add ppp profile
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/ppp/profile/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to display all ppp profile
46 | * @return type array
47 | *
48 | */
49 | public function getAll() {
50 | $sentence = new SentenceUtil();
51 | $sentence->fromCommand("/ppp/profile/getall");
52 | $this->talker->send($sentence);
53 | $rs = $this->talker->getResult();
54 | $i = 0;
55 | if ($i < $rs->size()) {
56 | return $rs->getResultArray();
57 | } else {
58 | return "No PPP Profile To Set, Please Your Add PPP Profile";
59 | }
60 | }
61 |
62 | /**
63 | * This method is used to remove ppp profile by id
64 | * @param type $id string
65 | * @return type array
66 | *
67 | */
68 | public function delete($id) {
69 | $sentence = new SentenceUtil();
70 | $sentence->addCommand("/ppp/profile/remove");
71 | $sentence->where(".id", "=", $id);
72 | $enable = $this->talker->send($sentence);
73 | return "Sucsess";
74 | }
75 |
76 | /**
77 | * This method is used to set or edit ppp profile by id
78 | * @param type $param array
79 | * @param type $id string
80 | * @return type array
81 | *
82 | */
83 | public function set($param, $id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->addCommand("/ppp/profile/set");
86 | foreach ($param as $name => $value) {
87 | $sentence->setAttribute($name, $value);
88 | }
89 | $sentence->where(".id", "=", $id);
90 | $this->talker->send($sentence);
91 | return "Sucsess";
92 | }
93 |
94 | /**
95 | * This method is used to display one ppp profile
96 | * in detail based on the id
97 | * @param type $id string
98 | * @return type array
99 | *
100 | */
101 | public function detail($id) {
102 | $sentence = new SentenceUtil();
103 | $sentence->fromCommand("/ppp/profile/print");
104 | $sentence->where(".id", "=", $id);
105 | $this->talker->send($sentence);
106 | $rs = $this->talker->getResult();
107 | $i = 0;
108 | if ($i < $rs->size()) {
109 | return $rs->getResultArray();
110 | } else {
111 | return "No PPP Profile With This id = " . $id;
112 | }
113 | }
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/PPP/Secret.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class Secret {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to add ppp secret
30 | * @param type $param array
31 | * @return type array
32 | *
33 | */
34 | public function add($param) {
35 | $sentence = new SentenceUtil();
36 | $sentence->addCommand("/ppp/secret/add");
37 | foreach ($param as $name => $value) {
38 | $sentence->setAttribute($name, $value);
39 | }
40 | $this->talker->send($sentence);
41 | return "Sucsess";
42 | }
43 |
44 | /**
45 | * This method is used to disable ppp secret
46 | * @param type $id string
47 | * @return type array
48 | *
49 | */
50 | public function disable($id) {
51 | $sentence = new SentenceUtil();
52 | $sentence->addCommand("/ppp/secret/disable");
53 | $sentence->where(".id", "=", $id);
54 | $this->talker->send($sentence);
55 | return "Sucsess";
56 | }
57 |
58 | /**
59 | * This method is used to enable ppp secret
60 | * @param type $id string
61 | * @return type array
62 | *
63 | */
64 | public function enable($id) {
65 | $sentence = new SentenceUtil();
66 | $sentence->addCommand("/ppp/secret/enable");
67 | $sentence->where(".id", "=", $id);
68 | $this->talker->send($sentence);
69 | return "Sucsess";
70 | }
71 |
72 | /**
73 | * This method is used to set or edit ppp secret
74 | * @param type $param array
75 | * @param type $id string
76 | * @return type array
77 | *
78 | */
79 | public function set($param, $id) {
80 | $sentence = new SentenceUtil();
81 | $sentence->addCommand("/ppp/secret/set");
82 | foreach ($param as $name => $value) {
83 | $sentence->setAttribute($name, $value);
84 | }
85 | $sentence->where(".id", "=", $id);
86 | $this->talker->send($sentence);
87 | return "Sucsess";
88 | }
89 |
90 | /**
91 | * This method is used to delete ppp secret
92 | * @param type $id string
93 | * @return type array
94 | */
95 | public function delete($id) {
96 | $sentence = new SentenceUtil();
97 | $sentence->addCommand("/ppp/secret/remove");
98 | $sentence->where(".id", "=", $id);
99 | $this->talker->send($sentence);
100 | return "Sucsess";
101 | }
102 |
103 | /**
104 | * This method is used to display all ppp secret
105 | * @return type array
106 | *
107 | */
108 | public function getAll() {
109 | $sentence = new SentenceUtil();
110 | $sentence->fromCommand("/ppp/secret/getall");
111 | $this->talker->send($sentence);
112 | $rs = $this->talker->getResult();
113 | $i = 0;
114 | if ($i < $rs->size()) {
115 | return $rs->getResultArray();
116 | } else {
117 | return "No PPP Secret To Set, Please Your Add PPP Secret";
118 | }
119 | }
120 |
121 | /**
122 | * This method is used to display one ppp secret
123 | * in detail based on the id
124 | * @param type $id not array, harus di deklarasikan
125 | * @return type array
126 | *
127 | */
128 | public function detail($id) {
129 | $sentence = new SentenceUtil();
130 | $sentence->fromCommand("/ppp/secret/print");
131 | $sentence->where(".id", "=", $id);
132 | $this->talker->send($sentence);
133 | $rs = $this->talker->getResult();
134 | $i = 0;
135 | if ($i < $rs->size()) {
136 | return $rs->getResultArray();
137 | } else {
138 | return "No PPP Secret With This id = " . $id;
139 | }
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/System/System.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class System {
17 |
18 | /**
19 | *
20 | * @var type array
21 | */
22 | private $talker;
23 |
24 | function __construct(Talker $talker) {
25 | $this->talker = $talker;
26 | }
27 |
28 | /**
29 | * This method is used to set systemn identity
30 | * @param type $name string
31 | * @return type array
32 | */
33 | public function set_identity($name) {
34 | $sentence = new SentenceUtil();
35 | $sentence->addCommand("/system/identity/set");
36 | $sentence->setAttribute("name", $name);
37 | $this->talker->send($sentence);
38 | return "Sucsess";
39 | }
40 |
41 | /**
42 | * This method is used to display all system identiy
43 | * @return type array
44 | */
45 | public function get_all_identity() {
46 | $sentence = new SentenceUtil();
47 | $sentence->fromCommand("/system/identity/getall");
48 | $this->talker->send($sentence);
49 | $rs = $this->talker->getResult();
50 | return $rs->getResultArray();
51 | }
52 |
53 | /**
54 | * This method is used to display all system clock
55 | * @return type array
56 | */
57 | public function get_all_clock() {
58 | $sentence = new SentenceUtil();
59 | $sentence->fromCommand("/system/clock/getall");
60 | $this->talker->send($sentence);
61 | $rs = $this->talker->getResult();
62 | $i = 0;
63 | if ($i < $rs->size()) {
64 | return $rs->getResultArray();
65 | }
66 | }
67 |
68 | /**
69 | * This method is used to system bacup save
70 | * @param type $name string
71 | * @return type array
72 | */
73 | public function save_backup($name) {
74 | $sentence = new SentenceUtil();
75 | $sentence->addCommand("/system/backup/save");
76 | $sentence->setAttribute("name", $name);
77 | $this->talker->send($sentence);
78 | return "Sucsess";
79 | }
80 |
81 | /**
82 | * This method is used to system backup load
83 | * @param type $name string
84 | * @return type array
85 | */
86 | public function load_backup($name) {
87 | $sentence = new SentenceUtil();
88 | $sentence->addCommand("/system/backup/load");
89 | $sentence->setAttribute("name", $name);
90 | $this->talker->send($sentence);
91 | return "Sucsess";
92 | }
93 |
94 | /**
95 | * This method is used to display all system history
96 | * @return type array
97 | */
98 | public function get_all_history() {
99 | $sentence = new SentenceUtil();
100 | $sentence->fromCommand("/system/history/getall");
101 | $this->talker->send($sentence);
102 | $rs = $this->talker->getResult();
103 | $i = 0;
104 | if ($i < $rs->size()) {
105 | return $rs->getResultArray();
106 | } else {
107 | return "No History";
108 | }
109 | }
110 |
111 | /**
112 | * This method is used to display all system license
113 | * @return type array
114 | */
115 | public function get_all_license() {
116 | $sentence = new SentenceUtil();
117 | $sentence->fromCommand("/system/license/getall");
118 | $this->talker->send($sentence);
119 | $rs = $this->talker->getResult();
120 | $i = 0;
121 | if ($i < $rs->size()) {
122 | return $rs->getResultArray();
123 | }
124 | }
125 |
126 | /**
127 | * This method is used to display all system routerboard
128 | * @return type array
129 | */
130 | public function get_all_routerboard() {
131 | $sentence = new SentenceUtil();
132 | $sentence->fromCommand("/system/routerboard/getall");
133 | $this->talker->send($sentence);
134 | $rs = $this->talker->getResult();
135 | $i = 0;
136 | if ($i < $rs->size()) {
137 | return $rs->getResultArray();
138 | }
139 | }
140 |
141 | /**
142 | * This method is used to system reset configuration
143 | * @param type $keep_users string (yes or no)
144 | * @param type $no_defaults string (yes or no)
145 | * @param type $skip_backup string (yes or no)
146 | * @return type array
147 | */
148 | public function reset($keep_users, $no_defaults, $skip_backup) {
149 | $sentence = new SentenceUtil();
150 | $sentence->addCommand("/ip/address/add");
151 | $sentence->setAttribute("keep-users", $keep_users);
152 | $sentence->setAttribute("no-defaults", $no_defaults);
153 | $sentence->setAttribute("skip-backup", $skip_backup);
154 | $this->talker->send($sentence);
155 | return "Sucsess";
156 | }
157 |
158 | }
159 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Commands/System/SystemScheduler.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | */
16 | class SystemScheduler {
17 |
18 | private $talker;
19 |
20 | function __construct(Talker $talker) {
21 | $this->talker = $talker;
22 | }
23 |
24 | /**
25 | * This method used for add new system scheduler
26 | * @param type $param array
27 | * @return type array
28 | */
29 | public function add($param) {
30 | $sentence = new SentenceUtil();
31 | $sentence->addCommand("/system/scheduler/add");
32 | foreach ($param as $name => $value) {
33 | $sentence->setAttribute($name, $value);
34 | }
35 | $this->talker->send($sentence);
36 | return "Sucsess";
37 | }
38 |
39 | /**
40 | * This method used for disable system scheduler
41 | * @param type $id string
42 | * @return type array
43 | */
44 | public function disable($id) {
45 | $sentence = new SentenceUtil();
46 | $sentence->addCommand("/system/scheduler/disable");
47 | $sentence->where(".id", "=", $id);
48 | $this->talker->send($sentence);
49 | return "Sucsess";
50 | }
51 |
52 | /**
53 | * This method used for enable system scheduler
54 | * @param type $id string
55 | * @return type array
56 | */
57 | public function enable($id) {
58 | $sentence = new SentenceUtil();
59 | $sentence->addCommand("/system/scheduler/enable");
60 | $sentence->where(".id", "=", $id);
61 | $this->talker->send($sentence);
62 | return "Sucsess";
63 | }
64 |
65 | /**
66 | * This method used for delete system scheduler
67 | * @param type $id string
68 | * @return type array
69 | */
70 | public function delete($id) {
71 | $sentence = new SentenceUtil();
72 | $sentence->addCommand("/system/scheduler/remove");
73 | $sentence->where(".id", "=", $id);
74 | $this->talker->send($sentence);
75 | return "Sucsess";
76 | }
77 |
78 | /**
79 | * This method used for detail system scheduler
80 | * @param type $id string
81 | * @return type array
82 | */
83 | public function detail($id) {
84 | $sentence = new SentenceUtil();
85 | $sentence->fromCommand("/system/scheduler/print");
86 | $sentence->where(".id", "=", $id);
87 | $this->talker->send($sentence);
88 | $rs = $this->talker->getResult();
89 | $i = 0;
90 | if ($i < $rs->size()) {
91 | return $rs->getResultArray();
92 | } else {
93 | return "No System Scheduler With This id = " . $id;
94 | }
95 | }
96 |
97 | /**
98 | * This method used for set or edit system scheduler
99 | * @param type $param array
100 | * @param type $id string
101 | * @return type array
102 | */
103 | public function set($param, $id) {
104 | $sentence = new SentenceUtil();
105 | $sentence->addCommand("/system/scheduler/set");
106 | foreach ($param as $name => $value) {
107 | $sentence->setAttribute($name, $value);
108 | }
109 | $sentence->where(".id", "=", $id);
110 | $this->talker->send($sentence);
111 | return "Sucsess";
112 | }
113 |
114 | /**
115 | * This method used for get all system scheduler
116 | * @return type array
117 | */
118 | public function getAll() {
119 | $sentence = new SentenceUtil();
120 | $sentence->fromCommand("/system/scheduler/getall");
121 | $this->talker->send($sentence);
122 | $rs = $this->talker->getResult();
123 | $i = 0;
124 | if ($i < $rs->size()) {
125 | return $rs->getResultArray();
126 | } else {
127 | return "No System Scheduler To Set, Please Your Add System Scheduler";
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Core/Connector.php:
--------------------------------------------------------------------------------
1 |
13 | * @copyright Copyright (c) 2011, Virtual Think Team.
14 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 | * @category Libraries
16 | * @property StreamSender $sender
17 | * @property StreamReciever $reciever
18 | */
19 | class Connector {
20 |
21 | private $socket;
22 | private $sender;
23 | private $reciever;
24 | private $host;
25 | private $port;
26 | private $username;
27 | private $password;
28 | private $connected = FALSE;
29 | private $login = FALSE;
30 |
31 | public function __construct($host, $port, $username, $password) {
32 | $this->host = $host;
33 | $this->port = $port;
34 | $this->username = $username;
35 | $this->password = $password;
36 | $this->initStream();
37 | }
38 |
39 | public function isConnected() {
40 | return $this->connected;
41 | }
42 |
43 | public function isLogin() {
44 | return $this->login;
45 | }
46 |
47 | private function initStream() {
48 | $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
49 | $this->sender = new StreamSender($this->socket);
50 | $this->reciever = new StreamReciever($this->socket);
51 | }
52 |
53 | public function sendStream($command) {
54 | return $this->sender->send($command);
55 | }
56 |
57 | public function recieveStream() {
58 | return $this->reciever->reciever();
59 | }
60 |
61 | private function challanger($username, $password, $challange) {
62 | $chal = md5(chr(0) . $this->password . pack('H*', $challange));
63 | $login = "/login\n=name=" . $this->username . "\n=response=00" . $chal;
64 | return $login;
65 | }
66 |
67 | public function connect() {
68 | if (socket_connect($this->socket, $this->host, $this->port)) {
69 | $this->sendStream("/login");
70 | $rec = $this->recieveStream();
71 | if (!Util::contains($rec, "!trap") && strlen($rec) > 0) {
72 | $word = explode("\n", $rec);
73 | if (count($word) > 1) {
74 | $split = explode("=ret=", $word[2]);
75 | $challange = $split[1];
76 | $challanger = $this->challanger($this->username, $this->password, $challange);
77 | $this->sendStream($challanger);
78 | $res = $this->recieveStream();
79 | if (Util::contains($res, "!done") && !Util::contains($res, "!trap")) {
80 | $this->login = TRUE;
81 | }
82 | }
83 | }
84 | $this->connected = TRUE;
85 | } else {
86 | $this->connected = FALSE;
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Core/StreamReciever.php:
--------------------------------------------------------------------------------
1 |
9 | * @copyright Copyright (c) 2011, Virtual Think Team.
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 | * @category Libraries
12 | */
13 | class StreamReciever {
14 |
15 | private $closed = false;
16 | private $socket;
17 |
18 | function __construct($socket) {
19 | $this->socket = $socket;
20 | }
21 |
22 | public function isClosed() {
23 | return $this->closed;
24 | }
25 |
26 | private function protocolWordDecoder() {
27 | return $this->streamReciever($this->protocolLengthDecoder());
28 | }
29 |
30 | private function streamReciever($length) {
31 | $recieved = "";
32 | while (strlen($recieved) < $length) {
33 | $len = $length - strlen($recieved);
34 | $str = socket_read($this->socket, $len);
35 | if ($str == '') {
36 | $this->closed = TRUE;
37 | echo socket_last_error($this->socket);
38 | break;
39 | }
40 | $recieved = $recieved . $str;
41 | }
42 | return $recieved;
43 | }
44 |
45 | private function protocolLengthDecoder() {
46 | $byte = ord($this->streamReciever(1));
47 | if (($byte & 0x80) == 0x00) {
48 | $byte = $byte;
49 | } else if (($byte & 0xC0) == 0x80) {
50 | $byte &= ~0xC0;
51 | $byte <<= 8;
52 | $byte += ord($this->streamReciever(1));
53 | } else if (($byte & 0xE0) == 0xC0) {
54 | $byte &= ~0xE0;
55 | $byte <<= 8;
56 | $byte += ord($this->streamReciever(1));
57 | $byte <<= 8;
58 | $byte += ord($this->streamReciever(1));
59 | } else if (($byte & 0xF0) == 0xE0) {
60 | $byte &= ~0xF0;
61 | $byte <<= 8;
62 | $byte += ord($this->streamReciever(1));
63 | $byte <<= 8;
64 | $byte += ord($this->streamReciever(1));
65 | $byte <<= 8;
66 | $byte += ord($this->streamReciever(1));
67 | } else if (($byte & 0xF8) == 0x0F0) {
68 | $byte = ord($this->streamReciever(1));
69 | $byte <<= 8;
70 | $byte += ord($this->streamReciever(1));
71 | $byte <<= 8;
72 | $byte += ord($this->streamReciever(1));
73 | $byte <<= 8;
74 | $byte += ord($this->streamReciever(1));
75 | }
76 | return $byte;
77 | }
78 |
79 | public function reciever() {
80 | $out = "";
81 | $i = 0;
82 | while (true) {
83 | $word = $this->protocolWordDecoder();
84 | if (strlen($word) != 0 && strlen($word) > 0) {
85 | $out = $out . "\n" . $word;
86 | } else {
87 | break;
88 | }
89 | $i++;
90 | }
91 | return $out;
92 | }
93 |
94 | private function getSocketStatus() {
95 | return socket_get_status($this->socket);
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Core/StreamSender.php:
--------------------------------------------------------------------------------
1 |
9 | * @copyright Copyright (c) 2011, NuneNuh.
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 | * @category Libraries
12 | */
13 | class StreamSender {
14 |
15 | private $socket;
16 |
17 | function __construct($socket) {
18 | $this->socket = $socket;
19 | }
20 |
21 | private function protocolLengthEncoder($command) {
22 | $length = strlen($command);
23 | switch ($length) {
24 | case $length < 0x80 :
25 | $this->streamSender(chr($length));
26 | break;
27 | case $length < 0x4000:
28 | $length |= 0x8000;
29 | $this->streamSender(chr(($length >> 8 ) & 0xFF));
30 | $this->streamSender(chr($length & 0xFF));
31 | break;
32 | case $length < 0x200000:
33 | $length |= 0xC00000;
34 | $this->streamSender(chr(($length >> 16) & 0xFF));
35 | $this->streamSender(chr(($length >> 8 ) & 0xFF));
36 | $this->streamSender(chr($length & 0xFF));
37 | break;
38 | case $length < 0x10000000:
39 | $length |= 0xE0000000;
40 | $this->streamSender(chr(($length >> 24 ) & 0xFF));
41 | $this->streamSender(chr(($length >> 16 ) & 0xFF));
42 | $this->streamSender(chr(($length >> 8 ) & 0xFF));
43 | $this->streamSender(chr($length & 0xFF));
44 | break;
45 | case $length >= 0x10000000:
46 | $this->streamSender(chr(0xF0));
47 | $this->streamSender(chr(($length >> 24) & 0x0FF));
48 | $this->streamSender(chr(($length >> 16) & 0x0FF));
49 | $this->streamSender(chr(($length >> 8 ) & 0x0FF));
50 | $this->streamSender(chr($length & 0x0FF));
51 | break;
52 | }
53 | }
54 |
55 | private function streamSender($command) {
56 | $i = 0;
57 | $out = 0;
58 | while ($i < strlen($command)) {
59 | $out = socket_write($this->socket, $command);
60 | if ($out == 0) {
61 | echo "Connection closed";
62 | echo socket_last_error($this->socket);
63 | break;
64 | }
65 | $i += $out;
66 | }
67 | }
68 |
69 | private function protocolWordEncoder($command) {
70 | $this->protocolLengthEncoder($command);
71 | $this->streamSender($command);
72 | }
73 |
74 | public function send($command) {
75 | $com_array = explode("\n", $command);
76 | if (count($com_array) > 2) {
77 | $ret = NULL;
78 | foreach ($com_array as $data) {
79 | $com = $data;
80 | $ret = $this->protocolWordEncoder($com);
81 | }
82 | $ret = $this->protocolWordEncoder('');
83 | return $ret;
84 | } else {
85 | $com = $com_array[0];
86 | $ret = $this->protocolWordEncoder($com);
87 | $ret = $this->protocolWordEncoder('');
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Entity/Attribute.php:
--------------------------------------------------------------------------------
1 |
9 | * @copyright Copyright (c) 2011, Virtual Think Team.
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 | * @category Libraries
12 | */
13 | class Attribute {
14 |
15 | private $clause;
16 | private $name;
17 | private $value;
18 |
19 | public function __construct($clause = '', $name = '', $value = '') {
20 | $this->clause = $clause;
21 | $this->name = $name;
22 | $this->value = $value;
23 | }
24 |
25 | public function setClause($clause) {
26 | $this->clause = $clause;
27 | }
28 |
29 | public function getClause() {
30 | return $this->clause;
31 | }
32 |
33 | public function setName($name) {
34 | $this->name = $name;
35 | }
36 |
37 | public function getName() {
38 | return $this->name;
39 | }
40 |
41 | public function setValue($value) {
42 | $this->value = $value;
43 | }
44 |
45 | public function getValue() {
46 | return $this->value;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Entity/Auth.php:
--------------------------------------------------------------------------------
1 | host = $host;
66 | $this->port = $port;
67 | $this->username = $username;
68 | $this->password = $password;
69 | $this->debug = $debug;
70 | $this->attempts = $attempts;
71 | $this->delay = $delay;
72 | $this->timeout = $timeout;
73 | }
74 |
75 | public function getHost() {
76 | return $this->host;
77 | }
78 |
79 | public function getPort() {
80 | return $this->port;
81 | }
82 |
83 | public function getUsername() {
84 | return $this->username;
85 | }
86 |
87 | public function getPassword() {
88 | return $this->password;
89 | }
90 |
91 | public function getDebug() {
92 | return $this->debug;
93 | }
94 |
95 | public function getAttempts() {
96 | return $this->attempts;
97 | }
98 |
99 | public function getDelay() {
100 | return $this->delay;
101 | }
102 |
103 | public function getTimeout() {
104 | return $this->timeout;
105 | }
106 |
107 | public function setHost($host) {
108 | $this->host = $host;
109 | }
110 |
111 | public function setPort($port) {
112 | $this->port = $port;
113 | }
114 |
115 | public function setUsername($username) {
116 | $this->username = $username;
117 | }
118 |
119 | public function setPassword($password) {
120 | $this->password = $password;
121 | }
122 |
123 | public function setDebug($debug) {
124 | $this->debug = $debug;
125 | }
126 |
127 | public function setAttempts($attempts) {
128 | $this->attempts = $attempts;
129 | }
130 |
131 | public function setDelay($delay) {
132 | $this->delay = $delay;
133 | }
134 |
135 | public function setTimeout($timeout) {
136 | $this->timeout = $timeout;
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/MikrotikAPI.php:
--------------------------------------------------------------------------------
1 |
8 | * @copyright Copyright (c) 2011, Virtual Think Team.
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 | * @category Libraries
11 | */
12 | class MikrotikAPI {
13 |
14 | /**
15 | * @access private
16 | * @var type Object
17 | */
18 | private $CI;
19 |
20 | /**
21 | * Instantiation of Class Mikrotik_Api
22 | * @access private
23 | * @var type array
24 | */
25 | private $param;
26 |
27 |
28 | /**
29 | *
30 | * @var Talker\Talker
31 | */
32 | private $talker;
33 |
34 | function __construct($param = array()) {
35 | $this->CI = & get_instance();
36 | $param_config = $this->CI->config->item('mikrotik');
37 | if (isset($param_config) && is_array($param_config)) {
38 | $this->param = $param_config;
39 | } else {
40 | $this->param = $param;
41 | }
42 | $this->talker = new Talker($this->param['host'], $this->param['port'], $this->param['username'], $this->param['password']);
43 | }
44 |
45 | /**
46 | * This method for call class Mapi IP
47 | * @access public
48 | * @return Object of Mapi_Ip
49 | */
50 | public function IP() {
51 | return new Mapi_Ip($this->talker);
52 | }
53 |
54 | /**
55 | * This method for call class Mapi Interface
56 | * @access public
57 | * @return Object of Mapi_Interface
58 | */
59 | public function interfaces() {
60 | return new Mapi_Interfaces($this->talker);
61 | }
62 |
63 | /**
64 | * This method for call class Mapi Ppp
65 | * @access public
66 | * @return Object of Mapi_Ppp
67 | */
68 | public function ppp() {
69 | return new Mapi_Ppp($this->talker);
70 | }
71 |
72 | /**
73 | * This method for call class Mapi_System
74 | * @access public
75 | * @return Mapi_System
76 | */
77 | public function system() {
78 | return new Mapi_System($this->talker);
79 | }
80 |
81 | /**
82 | * This method for call class Mapi_File
83 | * @access public
84 | * @return Mapi_File
85 | */
86 | public function file() {
87 | return new Mapi_File($this->talker);
88 | }
89 |
90 | /**
91 | * This metod used call class Mapi_System_Scheduler
92 | * @return Mapi_Ip
93 | */
94 | public function system_scheduler() {
95 | return new Mapi_System_Scheduler($this->talker);
96 | }
97 |
98 | /**
99 | *
100 | * @return \Talker
101 | */
102 | public function buildCommand() {
103 | return new Talker($this->param['host'], $this->param['port'], $this->param['username'], $this->param['password']);
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Talker/Talker.php:
--------------------------------------------------------------------------------
1 |
12 | * @copyright Copyright (c) 2011, Virtual Think Team.
13 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 | * @category Libraries
15 | * @property TalkerReciever
16 | * @property TalkerSender
17 | */
18 | class Talker {
19 |
20 | private $sender;
21 | private $reciever;
22 | private $auth;
23 | private $connector;
24 |
25 | // private $param;
26 |
27 |
28 | public function __construct(Auth $auth) {
29 | // parent::__construct($auth->getHost(), $auth->getPort(), $auth->getUsername(), $auth->getPassword());
30 | // parent::connect();
31 | $this->auth = $auth;
32 | $this->connector = new Connector($auth->getHost(), $auth->getPort(), $auth->getUsername(), $auth->getPassword());
33 | $this->connector->connect();
34 | $this->sender = new TalkerSender($this->connector);
35 | $this->reciever = new TalkerReciever($this->connector);
36 | }
37 |
38 | /**
39 | *
40 | * @return type
41 | */
42 | public function isLogin() {
43 | // return parent::isLogin();
44 | }
45 |
46 | /**
47 | *
48 | * @return type
49 | */
50 | public function isConnected() {
51 | // return parent::isConnected();
52 | }
53 |
54 | /**
55 | *
56 | * @return type
57 | */
58 | public function isDebug() {
59 | return $this->auth->getDebug();
60 | }
61 |
62 | /**
63 | *
64 | * @param type $boolean
65 | */
66 | public function setDebug($boolean) {
67 | $this->auth->setDebug($boolean);
68 | $this->sender->setDebug($boolean);
69 | $this->reciever->setDebug($boolean);
70 | }
71 |
72 | /**
73 | *
74 | * @return type
75 | */
76 | public function isTrap() {
77 | return $this->reciever->isTrap();
78 | }
79 |
80 | /**
81 | *
82 | * @return type
83 | */
84 | public function isDone() {
85 | return $this->reciever->isDone();
86 | }
87 |
88 | /**
89 | *
90 | * @return type
91 | */
92 | public function isData() {
93 | return $this->reciever->isData();
94 | }
95 |
96 | /**
97 | *
98 | * @param type $sentence
99 | */
100 | public function send($sentence) {
101 | $this->sender->send($sentence);
102 | $this->reciever->doRecieving();
103 | }
104 |
105 | /**
106 | *
107 | * @return type
108 | */
109 | public function getResult() {
110 | return $this->reciever->getResult();
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Talker/TalkerReciever.php:
--------------------------------------------------------------------------------
1 |
15 | * @copyright Copyright (c) 2011, Virtual Think Team.
16 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
17 | * @category Libraries
18 | */
19 | class TalkerReciever {
20 |
21 | private $con;
22 | private $result;
23 | private $trap = FALSE;
24 | private $done = FALSE;
25 | private $re = FALSE;
26 | private $debug = FALSE;
27 |
28 | public function __construct(Connector $con) {
29 | $this->con = $con;
30 | $this->result = new ResultUtil();
31 | }
32 |
33 | public function isTrap() {
34 | return $this->trap;
35 | }
36 |
37 | public function isDone() {
38 | return $this->done;
39 | }
40 |
41 | public function isData() {
42 | return $this->re;
43 | }
44 |
45 | public function isDebug() {
46 | return $this->debug;
47 | }
48 |
49 | public function setDebug($boolean) {
50 | $this->debug = $boolean;
51 | }
52 |
53 | private function parseRawToList($raw) {
54 | $raw = trim($raw);
55 | if (!empty($raw)) {
56 | $list = new \ArrayObject();
57 | $token = explode("\n", $raw);
58 | $a = 1;
59 | while ($a < count($token)) {
60 | next($token);
61 | $attr = new Attribute();
62 | if (!(current($token) == "!re") && !(current($token) == "!trap")) {
63 | $split = explode("=", current($token));
64 | $attr->setName($split[1]);
65 | if (count($split) == 3) {
66 | $attr->setValue($split[2]);
67 | } else {
68 | $attr->setValue(NULL);
69 | }
70 | $list->append($attr);
71 | }
72 | $a++;
73 | }
74 | if ($list->count() != 0)
75 | $this->result->add($list);
76 | }
77 | }
78 |
79 | public function getResult() {
80 | return $this->result;
81 | }
82 |
83 | public function doRecieving() {
84 | $this->run();
85 | }
86 |
87 | private function runDebugger($string) {
88 | if ($this->isDebug()) {
89 | DebugDumper::dump($string);
90 | }
91 | }
92 |
93 | private function run() {
94 | $s = "";
95 | while (true) {
96 | $s = $this->con->recieveStream();
97 | if (Util::contains($s, "!re")) {
98 | $this->parseRawToList($s);
99 | $this->runDebugger($s);
100 | $this->re = TRUE;
101 | }
102 |
103 | if (Util::contains($s, "!trap")) {
104 | $this->runDebugger($s);
105 | $this->trap = TRUE;
106 | break;
107 | }
108 |
109 | if (Util::contains($s, "!done")) {
110 | $this->runDebugger($s);
111 | $this->done = TRUE;
112 | break;
113 | }
114 | }
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Talker/TalkerSender.php:
--------------------------------------------------------------------------------
1 |
15 | * @copyright Copyright (c) 2011, Virtual Think Team.
16 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
17 | * @category Libraries
18 | */
19 | class TalkerSender {
20 |
21 | private $debug = FALSE;
22 | private $con;
23 |
24 | public function __construct(Connector $con) {
25 | $this->con = $con;
26 | }
27 |
28 | public function send(SentenceUtil $sentence) {
29 | $cmd = $this->createSentence($sentence);
30 | $this->con->sendStream($cmd);
31 | }
32 |
33 | public function isDebug() {
34 | return $this->debug;
35 | }
36 |
37 | public function setDebug($boolean) {
38 | $this->debug = $boolean;
39 | }
40 |
41 | public function runDebugger($str) {
42 | if ($this->isDebug()) {
43 | DebugDumper::dump($str);
44 | }
45 | }
46 |
47 | private function sentenceWrapper(SentenceUtil $sentence) {
48 | $it = $sentence->getBuildCommand()->getIterator();
49 |
50 | $attr = new Attribute();
51 | while ($it->valid()) {
52 | if (Util::contains($it->current()->getClause(), "commandPrint") ||
53 | Util::contains($it->current()->getClause(), "commandReguler")) {
54 | $attr = $it->current();
55 | }
56 | $it->next();
57 | }
58 |
59 | $it->rewind();
60 |
61 | $out = new \ArrayObject();
62 | $out->append($attr);
63 | while ($it->valid()) {
64 | if (!Util::contains($it->current()->getClause(), "commandPrint") &&
65 | !Util::contains($it->current()->getClause(), "commandReguler")) {
66 | $out->append($it->current());
67 | }
68 | $it->next();
69 | }
70 | return $out;
71 | }
72 |
73 | private function createSentence(SentenceUtil $sentence) {
74 | $build = "";
75 | $sentence = $this->sentenceWrapper($sentence);
76 | $it = $sentence->getIterator();
77 | $cmd = "";
78 |
79 | while ($it->valid()) {
80 | $clause = $it->current()->getClause();
81 | $name = $it->current()->getName();
82 | $value = $it->current()->getValue();
83 |
84 | if (Util::contains($clause, "commandPrint")) {
85 | $build = $build . $value;
86 | $cmd = "print";
87 | } else if (Util::contains($clause, "commandReguler")) {
88 | $build = $build . $value;
89 | $cmd = "reguler";
90 | } else {
91 | if (Util::contains($name, "proplist") || Util::contains($name, "tag")) {
92 | $build = $build . "=." . $name . "=" . $value;
93 | }
94 |
95 | if ($clause == "where" && $cmd == "print") {
96 | $build = $build . "?" . $name . $value;
97 | }
98 |
99 | if ($clause == "where" && $cmd == "reguler") {
100 | $build = $build . $name . $value;
101 | }
102 |
103 | if ($clause == "whereNot" || $clause == "orWhere" ||
104 | $clause == "orWhereNot" || $clause == "andWhere" ||
105 | $clause == "andWhereNot") {
106 | $build = $build . $name . $value;
107 | }
108 |
109 | if ($clause == "setAttribute") {
110 | $build = $build . "=" . $name . "=" . $value;
111 | }
112 | }
113 | if ($it->valid())
114 | $build = $build . "\n";
115 | $it->next();
116 | }
117 | $this->runDebugger($build);
118 | return $build;
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Util/DebugDumper.php:
--------------------------------------------------------------------------------
1 | ";
16 | print_r($var);
17 | echo "";
18 | } else {
19 | echo "
";
20 | var_dump($var);
21 | echo "
";
22 | }
23 | } else {
24 | if ($detail == false) {
25 | echo "";
26 | echo $var;
27 | echo "
";
28 | } else {
29 | echo "";
30 | var_dump($var);
31 | echo "
";
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Util/ResultUtil.php:
--------------------------------------------------------------------------------
1 |
9 | * @copyright Copyright (c) 2011, Virtual Think Team.
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 | * @category Libraries
12 | */
13 | class ResultUtil {
14 |
15 | private $list;
16 | private $listAttr;
17 | private $itList;
18 |
19 | public function __construct() {
20 | $this->list = new \ArrayObject();
21 | $this->listAttr = new \ArrayObject();
22 | }
23 |
24 | public function getResult($mixed = '') {
25 | $value = NULL;
26 | if (gettype($mixed) == "string") {
27 | $it = $this->listAttr->getIterator();
28 | while ($it->valid()) {
29 | if ($it->current()->getName() == $mixed) {
30 | $value = $it->current()->getValue();
31 | }
32 | $it->next();
33 | }
34 | } else if (gettype($mixed) == "integer") {
35 | $it = $this->listAttr->getIterator();
36 | $value = $it->offsetGet($mixed)->getValue();
37 | } else {
38 | $value = NULL;
39 | }
40 | return $value;
41 | }
42 |
43 | public function getResultArray() {
44 | $ar = new \ArrayObject();
45 |
46 | while ($this->next()) {
47 | $it = $this->listAttr->getIterator();
48 | while ($it->valid()) {
49 | $tmpAr[$it->current()->getName()] = $it->current()->getValue();
50 | $it->next();
51 | }
52 | $ar->append($tmpAr);
53 | }
54 |
55 | return $ar->getArrayCopy();
56 | }
57 |
58 | private function fireOnChange() {
59 | $this->itList = $this->list->getIterator();
60 | $this->listAttr = $this->itList->current();
61 | }
62 |
63 | public function hasNext() {
64 | return $this->itList->valid();
65 | }
66 |
67 | public function next() {
68 | if ($this->hasNext()) {
69 | $this->listAttr = $this->itList->current();
70 | $this->itList->next();
71 | return TRUE;
72 | } else {
73 | return FALSE;
74 | }
75 | }
76 |
77 | public function size() {
78 | return $this->list->count();
79 | }
80 |
81 | public function add(\ArrayObject $object) {
82 | $this->list->append($object);
83 | $this->fireOnChange();
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Util/SentenceUtil.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright Copyright (c) 2011, Virtual Think Team.
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 | * @category Libraries
14 | */
15 | class SentenceUtil {
16 |
17 | private $list;
18 |
19 | public function __construct() {
20 | $this->list = new \ArrayObject();
21 | }
22 |
23 | public function select($attributeName) {
24 | $name = "";
25 | if (Util::contains($attributeName, " ")) {
26 | $token = explode(" ", $attributeName);
27 | $a = 0;
28 | while ($a < count($token)) {
29 | $name = $name . current($token);
30 | next($token);
31 | $a++;
32 | }
33 | } else {
34 | $name = $attributeName;
35 | }
36 |
37 | $this->list->append(new Attribute("select", "proplist", $name));
38 | }
39 |
40 | public function where($name, $operand, $value) {
41 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
42 | $build = trim($operand) . trim($name) . "=";
43 | $this->list->append(new Attribute("where", $build, trim($value)));
44 | } else {
45 | return FALSE;
46 | }
47 | }
48 |
49 | public function whereNot($name, $operand, $value) {
50 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
51 | $build = "?" . trim($operand) . trim($name) . "=";
52 | $this->list->append(new Attribute("whereNot", $build, trim($value)));
53 | $this->list->append(new Attribute("whereNot", "?#", "!"));
54 | return TRUE;
55 | } else {
56 | return FALSE;
57 | }
58 | }
59 |
60 | public function orWhere($name, $operand, $value) {
61 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
62 | $build = "?" . trim($operand) . trim($name) . "=";
63 | $this->list->append(new Attribute("whereNot", $build, trim($value)));
64 | $this->list->append(new Attribute("whereNot", "?#", "|"));
65 | return TRUE;
66 | } else {
67 | return FALSE;
68 | }
69 | }
70 |
71 | public function orWhereNot($name, $operand, $value) {
72 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
73 | $build = "?" . trim($operand) . trim($name) . "=";
74 | $this->list->append(new Attribute("whereNot", $build, trim($value)));
75 | $this->list->append(new Attribute("whereNot", "?#", "!"));
76 | $this->list->append(new Attribute("whereNot", "?#", "|"));
77 | return TRUE;
78 | } else {
79 | return FALSE;
80 | }
81 | }
82 |
83 | public function andWhere($name, $operand, $value) {
84 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
85 | $build = "?" . trim($operand) . trim($name) . "=";
86 | $this->list->append(new Attribute("whereNot", $build, trim($value)));
87 | $this->list->append(new Attribute("whereNot", "?#", "&"));
88 | return TRUE;
89 | } else {
90 | return FALSE;
91 | }
92 | }
93 |
94 | public function andWhereNot($name, $operand, $value) {
95 | if ($operand == "-" || $operand == "=" || $operand == "<" || $operand == ">") {
96 | $build = "?" . trim($operand) . trim($name) . "=";
97 | $this->list->append(new Attribute("whereNot", $build, trim($value)));
98 | $this->list->append(new Attribute("whereNot", "?#", "!"));
99 | $this->list->append(new Attribute("whereNot", "?#", "&"));
100 | return TRUE;
101 | } else {
102 | return FALSE;
103 | }
104 | }
105 |
106 | public function fromCommand($command) {
107 | $this->list->append(new Attribute("commandPrint", "command", $command));
108 | }
109 |
110 | public function addCommand($command) {
111 | $this->list->append(new Attribute("commandReguler", "command", $command));
112 | }
113 |
114 | public function setAttribute($name, $value) {
115 | $this->list->append(new Attribute("setAttribute", $name, $value));
116 | }
117 |
118 | public function getBuildCommand() {
119 | return $this->list;
120 | }
121 |
122 | public function add(Attribute $attr) {
123 | $this->list->append($attr);
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/src/MikrotikAPI/Util/Util.php:
--------------------------------------------------------------------------------
1 | setHost("172.18.1.254");
13 | $auth->setUsername("admin");
14 | $auth->setPassword("1261");
15 | $auth->setDebug(true);
16 |
17 |
18 | $talker = new Talker($auth);
19 | //$filter = new FirewallFilter($talker);
20 | //$a = $filter->getAll();
21 |
22 |
23 | $ipaddr = new Address($talker);
24 | $listIP = $ipaddr->getAll();
25 |
26 |
27 | MikrotikAPI\Util\DebugDumper::dump($listIP);
28 |
--------------------------------------------------------------------------------
/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | array($baseDir . '/test'),
10 | 'MikrotikAPI' => array($baseDir . '/src'),
11 | );
12 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | $path) {
31 | $loader->set($namespace, $path);
32 | }
33 |
34 | $classMap = require __DIR__ . '/autoload_classmap.php';
35 | if ($classMap) {
36 | $loader->addClassMap($classMap);
37 | }
38 |
39 | $loader->register(true);
40 |
41 | return $loader;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------