@@ -89,11 +89,7 @@ public function __construct($createRoot = false, $dataPath = null)
8989 "folder_permissions " => 0777
9090 ];
9191
92- $ this ->firewallConfigStore = new Store ("firewall_config " , $ this ->databaseDirectory , $ this ->storeConfiguration );
93-
94- $ this ->firewallFiltersStore = new Store ("firewall_filters " , $ this ->databaseDirectory , $ this ->storeConfiguration );
95-
96- $ this ->firewallFiltersDefaultStore = new Store ("firewall_filters_default " , $ this ->databaseDirectory , $ this ->storeConfiguration );
92+ $ this ->initStores ();
9793
9894 $ this ->getConfig ();
9995
@@ -128,6 +124,15 @@ public function __construct($createRoot = false, $dataPath = null)
128124 }
129125 }
130126
127+ public function initStores ()
128+ {
129+ $ this ->firewallConfigStore = new Store ("firewall_config " , $ this ->databaseDirectory , $ this ->storeConfiguration );
130+
131+ $ this ->firewallFiltersStore = new Store ("firewall_filters " , $ this ->databaseDirectory , $ this ->storeConfiguration );
132+
133+ $ this ->firewallFiltersDefaultStore = new Store ("firewall_filters_default " , $ this ->databaseDirectory , $ this ->storeConfiguration );
134+ }
135+
131136 public function getFirewallConfig ()
132137 {
133138 $ this ->getConfig ();
@@ -313,62 +318,86 @@ public function setConfigIp2locationKey($key)
313318
314319 public function setIp2locationBinFileCode ($ fileCode )
315320 {
316- if ($ fileCode === '' ) {
321+ if ($ fileCode === 'null ' ) {
322+ $ fileCode = null ;
323+ } else {
324+ $ fileCode = strtoupper ($ fileCode );
325+ }
326+
327+ if ($ fileCode &&
328+ ($ fileCode === '' ||
329+ ($ fileCode !== 'DB3LITEBINIPV6 ' && $ fileCode !== 'DB3BINIPV6 ' )
330+ )
331+ ) {
317332 $ this ->addResponse ('Please provide correct file code. ' , 1 );
318333
319334 return false ;
320335 }
321336
322- if ($ fileCode === 'null ' ) {
323- $ fileCode = null ;
324- }
325-
326- return $ this ->updateConfig (['ip2location_bin_file_code ' => strtoupper ($ fileCode )]);
337+ return $ this ->updateConfig (['ip2location_bin_file_code ' => $ fileCode ]);
327338 }
328339
329340 public function setIp2locationBinAccessMode ($ accessMode )
330341 {
331- if ($ accessMode === '' ) {
332- $ this ->addResponse ('Please provide correct file mode. ' , 1 );
333-
334- return false ;
335- }
336-
337342 if ($ accessMode === 'null ' ) {
338343 $ accessMode = null ;
344+ } else {
345+ $ accessMode = strtoupper ($ accessMode );
339346 }
340347
341- return $ this ->updateConfig (['ip2location_bin_access_mode ' => strtoupper ($ accessMode )]);
348+ if ($ accessMode &&
349+ ($ accessMode === '' ||
350+ ($ accessMode !== 'SHARED_MEMORY ' && $ accessMode !== 'MEMORY_CACHE ' && $ accessMode !== 'FILE_IO ' )
351+ )
352+ ) {
353+ $ this ->addResponse ('Please provide correct access mode. ' , 1 );
354+
355+ return false ;
356+ }
357+
358+ return $ this ->updateConfig (['ip2location_bin_access_mode ' => $ accessMode ]);
342359 }
343360
344361 public function setIp2locationProxyBinFileCode ($ fileCode )
345362 {
346- if ($ fileCode === '' ) {
363+ if ($ fileCode === 'null ' ) {
364+ $ fileCode = null ;
365+ } else {
366+ $ fileCode = strtoupper ($ fileCode );
367+ }
368+
369+ if ($ fileCode &&
370+ ($ fileCode === '' ||
371+ ($ fileCode !== 'PX3BIN ' && $ fileCode !== 'PX3LITEBIN ' )
372+ )
373+ ) {
347374 $ this ->addResponse ('Please provide correct proxy file code. ' , 1 );
348375
349376 return false ;
350377 }
351378
352- if ($ fileCode === 'null ' ) {
353- $ fileCode = null ;
354- }
355-
356- return $ this ->updateConfig (['ip2location_proxy_bin_file_code ' => strtoupper ($ fileCode )]);
379+ return $ this ->updateConfig (['ip2location_proxy_bin_file_code ' => $ fileCode ]);
357380 }
358381
359382 public function setIp2locationProxyBinAccessMode ($ accessMode )
360383 {
361- if ($ accessMode === '' ) {
362- $ this ->addResponse ('Please provide correct proxy file mode. ' , 1 );
363-
364- return false ;
365- }
366-
367384 if ($ accessMode === 'null ' ) {
368385 $ accessMode = null ;
386+ } else {
387+ $ accessMode = strtoupper ($ accessMode );
388+ }
389+
390+ if ($ accessMode &&
391+ ($ accessMode === '' ||
392+ ($ accessMode !== 'SHARED_MEMORY ' && $ accessMode !== 'MEMORY_CACHE ' && $ accessMode !== 'FILE_IO ' )
393+ )
394+ ) {
395+ $ this ->addResponse ('Please provide correct proxy access mode. ' , 1 );
396+
397+ return false ;
369398 }
370399
371- return $ this ->updateConfig (['ip2location_proxy_bin_access_mode ' => strtoupper ( $ accessMode) ]);
400+ return $ this ->updateConfig (['ip2location_proxy_bin_access_mode ' => $ accessMode ]);
372401 }
373402
374403 public function setConfigIp2locationIoKey ($ key )
@@ -415,7 +444,7 @@ public function setIp2locationPrimaryLookupMethod($lookupMethod)
415444 return false ;
416445 }
417446
418- return $ this ->updateConfig (['ip2location_primary_lookup_method ' => strtoupper ( $ lookupMethod) ]);
447+ return $ this ->updateConfig (['ip2location_primary_lookup_method ' => $ lookupMethod ]);
419448 }
420449
421450 public function setConfigIp2locationBinDownloadDate ()
0 commit comments