-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.cfc
More file actions
129 lines (127 loc) · 4.66 KB
/
Application.cfc
File metadata and controls
129 lines (127 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Application.cfc Config extends FW1
*/
component extends="org.corfield.framework" {
$ = {};
$.configPath = "/app/config/";
loadConfig();
include $.configPath & "appCFC/vars.cfm";
/**
* Sets up the application
*/
public void function setUpApplication() {
var xbf = "";
var loc = {};
loadConfig();
include $.configPath & "appCFC/setUpApplication.cfm";
return;
}
/**
* Sets up a Request
*/
public void function setupRequest() {
if( !structKeyExists( application, "config" ) ){
loadConfig();
}
if( getEnvironment() == "live" && cgi.SERVER_PORT is 80 ) {
var path = replace( cgi.query_string, "path_info=", "", "All" );
location( url="https://" & cgi.server_name & path, addtoken="false" );
}
getBeanFactory().getBean("SessionManageUserFacade").validateSession( getBeanFactory().getBean("config").user );
controller( "security.accessCheck" );
return;
}
/**
* Sets up a Error Request
*/
public void function onError( any exception, string event ){
var ignore = "path_info=/favicon.ico";
var env = getEnvironment();
if( findNocase( ignore, cgi.query_string ) ) {
return;
}
if( env == "live" ){
//send out an error email
var mailerService = new mail();
var mail_body = "";
mailerService.setTo( 'matt.g@meetingplay.com;carl.w@meetingplay.com' );
mailerService.setBcc( 'joshua.g@excelaweb.com' );
mailerService.setFrom( 'matt.g@meetingplay.com' );
mailerService.setSubject( 'MP ERROR: ' & arguments.event );
mailerService.setType("html");
savecontent variable="mail_body"{
WriteOutput("There was an error: " & exception.cause.message & "<br><br><HR /><br><br>" );
writedump( var=arguments.exception, label="Exception Error Struct" );
WriteOutput("<br><br>FORMS<br><hr /><br>" );
writedump( var=form, label="FORM Vars" );
WriteOutput("<br><br>URL<br><hr /><br>" );
writedump( var=url, label="URL Vars" );
}
mailerService.send( body=mail_body );
location( url='/applicationErrors/default/event/' & arguments.event & '/message/' & URLEncodedFormat( exception.cause.message ), addToken="no" );
}else{
super.onError( exception, event );
}
}
/**
* Gets the Current Environment
*/
public string function getEnvironment() {
var env = "dev";
var host = cgi.server_name;
if( host == "manage.meetingplay.com" ) {
env = "live";
}
else if( host.indexOf("local") != -1 ) {
env = "local";
}
return env;
}
/**
* Loads the config from json files
*/
public void function loadConfig() {
var path = expandPath( "/app/config/" );
var defaults = path & "default-config.json"; // ensures all the framework configuration settings are available
var sidebar = path & "sidebar.json"; // ensures all the framework configuration settings are available
var config = path & getEnvironment() & ".json"; // default config is the dev config just to be safe
if(!fileExists( config ) || !fileExists( defaults ) || !fileExists( sidebar ) ){
throw(type="mp.App", message="The configuration file config.json could not be found.");
}
else{
application['config'] = deserializeJSON( fileRead( defaults ) );
application['config']['sidebar'] = deserializeJSON( fileRead( sidebar ) );
structAppend(application.config, deserializeJSON( fileRead( config ) ) );
if( structKeyExists( application.config, "mappings" ) ) {
if( structKeyExists( application.config.mappings, "cdn" ) ) {
application['config']['paths']['cdn_image_upload_dir'] = expandpath( application.config.mappings.cdn & "images/" );
application['config']['paths']['cdn_file_upload_dir'] = expandpath( application.config.mappings.cdn & "files/" );
application['config']['paths']['cdn_temp_upload_dir'] = expandpath( application.config.mappings.cdn & "temp/" );
if( !directoryExists( application.config.paths.cdn_file_upload_dir ) ) {
DirectoryCreate( application.config.paths.cdn_file_upload_dir & "temp/" );
DirectoryCreate( application.config.paths.cdn_file_upload_dir & "events/" );
}
if( !directoryExists( application.config.paths.cdn_image_upload_dir ) ) {
DirectoryCreate( application.config.paths.cdn_image_upload_dir & "temp/" );
DirectoryCreate( application.config.paths.cdn_image_upload_dir & "events/" );
}
}
}
}
return;
}
/**
* Gets the FW/1 Settings
*/
public struct function getFWSettings() {
return variables.framework;
}
public void function die(){
for( var i=1; i <= arrayLen( arguments ); i++ ){
writeoutput( '<br />' );
writedump( arguments[i] );
writeoutput( '<br /><br /><hr /><br /><br />' );
}
abort;
}
}