@@ -37,7 +37,7 @@ function is_iterable($var)
37
37
|| $ var instanceof IteratorAggregate
38
38
);
39
39
}
40
-
40
+
41
41
/**
42
42
* Print text for debug purposes
43
43
*
@@ -50,10 +50,10 @@ function debug($text)
50
50
if ($ this ->debug )
51
51
echo $ text . "\n" ;
52
52
}
53
-
54
-
53
+
54
+
55
55
/**
56
- *
56
+ *
57
57
*
58
58
* @param string $length
59
59
*
@@ -76,8 +76,8 @@ function encode_length($length)
76
76
$ length = chr (0xF0 ) . chr (($ length >> 24 ) & 0xFF ) . chr (($ length >> 16 ) & 0xFF ) . chr (($ length >> 8 ) & 0xFF ) . chr ($ length & 0xFF );
77
77
return $ length ;
78
78
}
79
-
80
-
79
+
80
+
81
81
/**
82
82
* Login to RouterOS
83
83
*
@@ -122,8 +122,8 @@ function connect($ip, $login, $password)
122
122
$ this ->debug ('Error... ' );
123
123
return $ this ->connected ;
124
124
}
125
-
126
-
125
+
126
+
127
127
/**
128
128
* Disconnect from RouterOS
129
129
*
@@ -135,8 +135,8 @@ function disconnect()
135
135
$ this ->connected = false ;
136
136
$ this ->debug ('Disconnected... ' );
137
137
}
138
-
139
-
138
+
139
+
140
140
/**
141
141
* Parse response from Router OS
142
142
*
@@ -166,8 +166,8 @@ function parse_response($response)
166
166
if ($ MATCHES [0 ][0 ] == 'ret ' ) {
167
167
$ singlevalue = $ MATCHES [0 ][1 ];
168
168
}
169
- $ CURRENT [$ MATCHES [0 ][0 ]] = (isset ($ MATCHES [0 ][1 ]) ? $ MATCHES [0 ][1 ] : '' );
170
- }
169
+ $ CURRENT [$ MATCHES [0 ][0 ]] = (isset ($ MATCHES [0 ][1 ]) ? $ MATCHES [0 ][1 ] : '' );
170
+ }
171
171
}
172
172
}
173
173
if (empty ($ PARSED ) && !is_null ($ singlevalue )) {
@@ -177,8 +177,8 @@ function parse_response($response)
177
177
} else
178
178
return array ();
179
179
}
180
-
181
-
180
+
181
+
182
182
/**
183
183
* Parse response from Router OS
184
184
*
@@ -209,7 +209,7 @@ function parse_response4smarty($response)
209
209
$ singlevalue = $ MATCHES [0 ][1 ];
210
210
}
211
211
$ CURRENT [$ MATCHES [0 ][0 ]] = (isset ($ MATCHES [0 ][1 ]) ? $ MATCHES [0 ][1 ] : '' );
212
- }
212
+ }
213
213
}
214
214
}
215
215
foreach ($ PARSED as $ key => $ value ) {
@@ -223,8 +223,8 @@ function parse_response4smarty($response)
223
223
return array ();
224
224
}
225
225
}
226
-
227
-
226
+
227
+
228
228
/**
229
229
* Change "-" and "/" from array key to "_"
230
230
*
@@ -249,8 +249,8 @@ function array_change_key_name(&$array)
249
249
return $ array ;
250
250
}
251
251
}
252
-
253
-
252
+
253
+
254
254
/**
255
255
* Read data from Router OS
256
256
*
@@ -295,9 +295,9 @@ function read($parse = true)
295
295
} else {
296
296
$ LENGTH = $ BYTE ;
297
297
}
298
-
299
- $ _ = "" ;
300
-
298
+
299
+ $ _ = "" ;
300
+
301
301
// If we have got more characters to read, read them in.
302
302
if ($ LENGTH > 0 ) {
303
303
$ _ = "" ;
@@ -323,8 +323,8 @@ function read($parse = true)
323
323
$ RESPONSE = $ this ->parse_response ($ RESPONSE );
324
324
return $ RESPONSE ;
325
325
}
326
-
327
-
326
+
327
+
328
328
/**
329
329
* Write (send) data to Router OS
330
330
*
@@ -354,8 +354,8 @@ function write($command, $param2 = true)
354
354
} else
355
355
return false ;
356
356
}
357
-
358
-
357
+
358
+
359
359
/**
360
360
* Write (send) data to Router OS
361
361
*
@@ -389,5 +389,15 @@ function comm($com, $arr = array())
389
389
}
390
390
return $ this ->read ();
391
391
}
392
+
393
+ /**
394
+ * Standard destructor
395
+ *
396
+ * @return void
397
+ */
398
+ function __destruct ()
399
+ {
400
+ $ this ->disconnect ();
401
+ }
392
402
}
393
403
?>
0 commit comments