Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. <cfcomponent output="false">
  2.  
  3. <cfset this.name = "Thor" />
  4. <cfset this.applicationTimeout = createTimeSpan(1,0,0,0) />
  5. <cfset this.clientManagement = false />
  6. <cfset this.clientStorage = "registry" />
  7. <cfset this.loginStorage = "session" />
  8. <cfset this.sessionManagement = true />
  9. <cfset this.sessionTimeout = createTimeSpan(0,1,0,0) />
  10. <cfset this.setClientCookies = true />
  11. <cfset this.setDomainCookies = false />
  12. <cfset this.scriptProtect = "all" />
  13.  
  14. <cffunction name="onApplicationStart" returnType="boolean" output="false">
  15.  
  16. <cfinclude template="configure.cfm">
  17. <cfscript>
  18. // config // environment-specific
  19. application.stuConfig = structNew();
  20. application.stuConfig.appName = CONFappName;
  21. application.stuConfig.comPath = CONFcomPath;
  22. application.stuConfig.dsn = CONFdsn;
  23. application.stuConfig.serverSlash = CONFserverSlash; // "\" for windows; "/" for unix;
  24. application.stuConfig.encoding = CONFencoding;
  25. application.stuConfig.env = CONFenv;
  26. application.stuConfig.version = CONFversion;
  27. application.stuConfig.crumbicon = CONFcrumbicon;
  28. application.stuConfig.szDelimFld = CONFszDelimfld; // 8 is the BACK-SPACE character.
  29. application.stuConfig.szDelimVal = CONFszDelimval;
  30. application.stuConfig.nDefaultRecsPerPage = CONFnDefaultRecsPerPage;
  31. application.stuConfig.szDefaultWildcardType = CONFszDefaultWildcardType;
  32. application.stuConfig.nMenuTotalsCacheMinutes = CONFnMenuTotalsCacheMinutes;
  33. application.stuConfig.stuFileTransfer = structNew();
  34. application.stuConfig.stuFileTransfer.confirmToGw = CONFconfirmToGw;
  35.  
  36. // mail
  37. application.stuMail = structNew();
  38. application.stumail.user = CONFmailuser;
  39. application.stumail.userpwd = CONFmailuserpwd; // no security problem: this user has very little permissions
  40. application.stumail.feedBack = CONFmailFeedback;
  41.  
  42. // paths // environment-specific
  43. application.stuPaths = structNew();
  44. application.stuPaths.websiteRoot = CONFwebsiteRoot;
  45. application.stuPaths.websiteURL = "#application.stuPaths.websiteRoot#/index.cfm";
  46. application.stuPaths.tempDir = CONFtempDir;
  47. application.stuPaths.tempDirUnc = CONFtempDirUnc;
  48. application.stuPaths.scancollectDir = CONFscancollectDir;
  49. application.stuPaths.rootPath = CONFrootpath;
  50. application.stuPaths.UTF8 = "#application.stuPaths.rootPath#\bin\utf8.exe";
  51. application.stuPaths.relPathToCbisfiletransfer = CONFrelPathToCbisfiletransfer;
  52.  
  53. // exporting documents/attachments out of ThOR/CBIS
  54. application.stuImpExp = structNew();
  55. application.stuImpExp.pathToExportDir = CONFpathToExportDir;
  56. application.stuImpExp.OLAFPlaceholderEntityId = CONFOLAFPlaceholderEntityId;
  57.  
  58. application.stuCBIS = structNew();
  59. application.stuCBIS.username = "";
  60. application.stuCBIS.pwd = "";
  61. application.stuCBIS.server = "";
  62. application.stuCBIS.altserver = "";
  63. application.stuCBIS.ldapport = "";
  64. application.stuCBIS.ldapStart = "";
  65.  
  66. // Fake vars for cbisfiletransfer sendfile
  67. application.stuSendfileFakeVars = structNew();
  68. application.stuSendfileFakeVars.nMaxBufferSize = CONFfakenMaxBufferSize;
  69. application.stuSendfileFakeVars.szEnvironement = CONFfakeszEnvironement;
  70. application.stuSendfileFakeVars.szApprovedToGW = CONFfakeszApprovedToGW;
  71.  
  72. // initialise objects
  73. application.stuObjs = structNew();
  74. application.stuObjs.UserManager = createObject("component", "#application.stuConfig.comPath#.UserManager").init(dsn=application.stuConfig.dsn);
  75. application.stuObjs.SecurityManager = createObject("component", "#application.stuConfig.comPath#.SecurityManager").init(dsn=application.stuConfig.dsn);
  76. application.stuObjs.Utilities = createObject("component", "#application.stuConfig.comPath#.Utilities").init(dsn=application.stuConfig.dsn);
  77. application.stuObjs.CFJson = createObject("component", "#application.stuConfig.comPath#.json");
  78. application.stuObjs.Gateway = createObject("component", "#application.stuConfig.comPath#.Gateway").init(dsn=application.stuConfig.dsn, OLAFPlaceholderEntityId=application.stuImpExp.OLAFPlaceholderEntityId, relPathToCbisfiletransfer=application.stuPaths.relPathToCbisfiletransfer);
  79. application.stuObjs.CFJson = createObject("component", "#application.stuConfig.comPath#.json");
  80. application.stuObjs.ZipUtilities = createObject("component", "#application.stuConfig.comPath#.ZipUtilities");
  81. </cfscript>
  82.  
  83. <!---
  84. <cfdump var="#application.stuObjs.Utilities#"><cfabort>
  85. --->
  86.  
  87. <cfreturn true />
  88. </cffunction>
  89.  
  90. <cffunction name="onApplicationEnd" returnType="void" output="false">
  91. <cfargument name="applicationScope" required="true" />
  92. </cffunction>
  93.  
  94. <cffunction name="onSessionStart" returnType="void" output="false">
  95. <cfscript>
  96. application.stuObjs.UserManager.initialiseUserSession();
  97. </cfscript>
  98. </cffunction>
  99.  
  100. <cffunction name="onSessionEnd" returnType="void" output="false">
  101. <cfargument name="sessionScope" type="struct" required="true" />
  102. <cfargument name="appScope" type="struct" required="false" />
  103. </cffunction>
  104.  
  105. <cffunction name="onRequestStart" returnType="boolean" output="false">
  106. <cfargument name="thePage" type="string" required="true" />
  107.  
  108. <!--- TEMP. Re-init app scope on every page call. But remove this when we have all our objects set up. --->
  109. <cfset onApplicationStart() />
  110.  
  111. <cfif not isdefined("session.stuUser.hasAccess") >
  112. <cfset onSessionStart() />
  113. <script language="javascript">alert("unexpected re-initialisation of session???");</script>
  114. </cfif>
  115.  
  116. <!--- Test if logged in --->
  117. <cfinvoke component="#application.stuObjs.UserManager#" method="isUserAuthorised" />
  118.  
  119. <!--- If user is in session, make sure the db is up, using the user's own credentials. --->
  120. <cfif session.stuUser.hasAccess>
  121. <cftry>
  122. <cfquery name="isDatabaseUp" datasource="#application.stuConfig.dsn#" username="#session.stuUser.Logon#" password="#session.stuUser.Password#">
  123. select sysdate from dual
  124. </cfquery>
  125. <cfcatch type="database">
  126. Database is not available. Please contact DBA!<cfabort />
  127. </cfcatch>
  128. </cftry>
  129. </cfif>
  130.  
  131. <cfreturn true />
  132. </cffunction>
  133.  
  134. <cffunction name="onRequestEnd" returnType="void" output="false">
  135. <cfargument name="thePage" type="string" required="true" />
  136. </cffunction>
  137.  
  138. <cffunction name="onError" returnType="void" output="false">
  139. <cfargument name="exception" required="true" />
  140. <cfargument name="eventname" type="string" required="true" />
  141.  
  142. <cfdump var="#arguments#" /><cfabort>
  143. Do something more pretty
  144. <!--- --->
  145. <cfinclude template="functions/err_req.cfm">
  146. <cfabort />
  147. </cffunction>
  148.  
  149. </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement