@@ -240,4 +240,73 @@ public function fetchRBCronAction()
240
240
241
241
return $ result ;
242
242
}
243
+
244
+ /**
245
+ * get action
246
+ * @return array
247
+ */
248
+ public function getAction ()
249
+ {
250
+ $ result = parent ::getAction ();
251
+ if (isset ($ result ['proxy ' ]['forward ' ]['acl ' ]['whiteList ' ])) {
252
+ $ result ['proxy ' ]['forward ' ]['acl ' ]['whiteList ' ] = self ::decode ($ result ['proxy ' ]['forward ' ]['acl ' ]['whiteList ' ]);
253
+ }
254
+ if (isset ($ result ['proxy ' ]['forward ' ]['acl ' ]['blackList ' ])) {
255
+ $ result ['proxy ' ]['forward ' ]['acl ' ]['blackList ' ] = self ::decode ($ result ['proxy ' ]['forward ' ]['acl ' ]['blackList ' ]);
256
+ }
257
+ if (isset ($ result ['proxy ' ]['forward ' ]['icap ' ]['exclude ' ])) {
258
+ $ result ['proxy ' ]['forward ' ]['icap ' ]['exclude ' ] = self ::decode ($ result ['proxy ' ]['forward ' ]['icap ' ]['exclude ' ]);
259
+ }
260
+ return $ result ;
261
+ }
262
+
263
+ /**
264
+ * set action
265
+ * @return array status
266
+ */
267
+ public function setAction ()
268
+ {
269
+ $ result = parent ::setAction ();
270
+ $ mdlProxy = $ this ->getModel ();
271
+ if (isset ($ mdlProxy ->forward ->acl ->whiteList )) {
272
+ $ mdlProxy ->forward ->acl ->whiteList = self ::decode ($ mdlProxy ->forward ->acl ->whiteList );
273
+ }
274
+ if (isset ($ mdlProxy ->forward ->acl ->blackList )) {
275
+ $ mdlProxy ->forward ->acl ->blackList = self ::decode ($ mdlProxy ->forward ->acl ->blackList );
276
+ }
277
+ if (isset ($ mdlProxy ->forward ->icap ->exclude )) {
278
+ $ mdlProxy ->forward ->icap ->exclude = self ::decode ($ mdlProxy ->forward ->icap ->exclude );
279
+ }
280
+ return $ result ;
281
+ }
282
+
283
+ /**
284
+ * Encode a given UTF-8 domain name
285
+ * @param string Domain name (UTF-8 or UCS-4)
286
+ * @return string Encoded Domain name (ACE string)
287
+ */
288
+ public static function encode ($ domains )
289
+ {
290
+ $ result = array ();
291
+ foreach (explode (", " , $ domains ) as $ domain ) {
292
+ if ($ domain != "" ) {
293
+ $ result [] = ($ domain [0 ] == ". " ? ". " : "" ) . idn_to_ascii ($ domain );
294
+ }
295
+ }
296
+ return implode (", " , $ result );
297
+ }
298
+
299
+ /**
300
+ * Decode a given ACE domain name
301
+ * @param string Domain name (ACE string)
302
+ * @return string Decoded Domain name (UTF-8 or UCS-4)
303
+ */
304
+ public static function decode ($ domains )
305
+ {
306
+ $ result = array ();
307
+ foreach ($ domains as $ domain => $ element ) {
308
+ $ result [idn_to_utf8 ($ domain )] = array ('value ' => idn_to_utf8 ($ element ['value ' ]), 'selected ' => $ element ['selected ' ]);
309
+ }
310
+ return $ result ;
311
+ }
243
312
}
0 commit comments