Guest User

Untitled

a guest
Jun 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. component {
  2. function init(required string configFile) {
  3. variables.configFile = arguments.configFile;
  4. variables.loadSections = ["common", CGI.SERVER_NAME];
  5.  
  6. return getConfig();
  7. }
  8.  
  9. private function getConfig() {
  10. var config = StructNew();
  11. var sections = getProfileSections(variables.configFile);
  12.  
  13. // Load settings applicable to this environment
  14. for(var i=1; i LTE ArrayLen(variables.loadSections); i++) {
  15. var currentSection = variables.loadSections[i];
  16.  
  17. // Verify section exists
  18. if (StructKeyExists(sections, currentSection)) {
  19. var keyList = sections[currentSection];
  20.  
  21. for(var j=1; j LTE ListLen(keyList); j++) {
  22. var currentKey = ListGetAt(keyList, j);
  23. var currentKeyValue = GetProfileString(variables.configFile, currentSection, currentKey);
  24.  
  25. // Append setting (overwrite common settings if a server-specific value exists)
  26. StructInsert(config, currentKey, currentKeyValue, True);
  27. }
  28. }
  29. }
  30. return config;
  31. }
  32. }
Add Comment
Please, Sign In to add comment