Skip to content

Commit 572d2c5

Browse files
committed
Auto-generate client-side config file, if not found or error.
1 parent 179e8ad commit 572d2c5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/net/authorize/util/ANetSensitiveFields.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ class ANetSensitiveFields
1010

1111
private static function fetchFromConfigFiles(){
1212
$configFilePath = dirname(__FILE__) . "/" . ANET_SENSITIVE_XMLTAGS_JSON_FILE;
13-
$userConfigFile = ANET_SENSITIVE_XMLTAGS_JSON_FILE;
14-
$presentUserConfigFile = file_exists($userConfigFile);
13+
$userConfigFilePath = ANET_SENSITIVE_XMLTAGS_JSON_FILE;
14+
$presentUserConfigFile = file_exists($userConfigFilePath);
1515
if ($presentUserConfigFile) { //client config for tags
1616
//read list of tags(and associate regex-patterns and replacements) from .json file
17-
$jsonFileObejct = json_decode(file_get_contents($userConfigFile));
17+
$jsonFileObejct = json_decode(file_get_contents($userConfigFilePath));
1818
$sensitiveTags = $jsonFileObejct->sensitiveTags;
1919
self::$sensitiveStringRegexes = $jsonFileObejct->sensitiveStringRegexes;
2020
if (json_last_error() === JSON_ERROR_NONE) {// JSON is valid
2121
}
2222
else{
23-
echo "ERROR: Invalid json in: " . $userConfigFile . " json_last_error_msg : " . json_last_error_msg();
23+
echo "ERROR: Invalid json in: " . $userConfigFilePath . " json_last_error_msg : " . json_last_error_msg();
2424
$presentUserConfigFile = false;
2525
}
2626
}
@@ -29,6 +29,7 @@ private static function fetchFromConfigFiles(){
2929
exit("ERROR: No config file: " . $configFilePath);
3030
}
3131
$jsonFileObejct = json_decode(file_get_contents($configFilePath));
32+
file_put_contents($userConfigFilePath, json_encode($jsonFileObejct, JSON_PRETTY_PRINT));
3233
$sensitiveTags = $jsonFileObejct->sensitiveTags;
3334
self::$sensitiveStringRegexes = $jsonFileObejct->sensitiveStringRegexes;
3435
if (json_last_error() === JSON_ERROR_NONE) {

0 commit comments

Comments
 (0)