5
5
6
6
// Create a new config file if it doesn't exist yet.
7
7
// The reason we create it, is so it has PHP write permissions, meaning we can update it later
8
- if (!file_exists (dirname ( __FILE__ ) ."/ " .$ configSettings )) {
8
+ if (!file_exists (__DIR__ ."/ " .$ configSettings )) {
9
9
// Include our params to make use of (as $newConfigSettingsFile)
10
- include (dirname ( __FILE__ ) ."/settings-system-params.php " );
11
- if ($ fConfigSettings =fopen (dirname ( __FILE__ ) ."/ " .$ configSettings ,'w ' )) {
10
+ include (__DIR__ ."/settings-system-params.php " );
11
+ if ($ fConfigSettings =fopen (__DIR__ ."/ " .$ configSettings ,'w ' )) {
12
12
fwrite ($ fConfigSettings ,$ newConfigSettingsFile );
13
13
fclose ($ fConfigSettings );
14
14
}else {
17
17
}
18
18
19
19
// Load config settings
20
- include (dirname ( __FILE__ ) ."/ " .$ configSettings );
20
+ include (__DIR__ ."/ " .$ configSettings );
21
21
22
22
// Load common functions
23
- include_once (dirname ( __FILE__ ) ."/settings-common.php " );
23
+ include_once (__DIR__ ."/settings-common.php " );
24
24
25
25
// Establish user settings file
26
26
$ username ="" ;
32
32
$ setPWorLogin ="login " ;
33
33
34
34
// Create user settings file if it doesn't exist
35
- if (!file_exists (dirname ( __FILE__ ) ."/ " .$ settingsFile ) &&$ ICEcoderSettings ['enableRegistration ' ]) {
36
- if (!copy (dirname ( __FILE__ ) ."/ " .$ configUsersTemplate ,dirname ( __FILE__ ) ."/ " .$ settingsFile )) {
35
+ if (!file_exists (__DIR__ ."/ " .$ settingsFile ) &&$ ICEcoderSettings ['enableRegistration ' ]) {
36
+ if (!copy (__DIR__ ."/ " .$ configUsersTemplate ,__DIR__ ."/ " .$ settingsFile )) {
37
37
die ("Couldn't create $ settingsFile. Maybe you need write permissions on the lib folder? " );
38
38
}
39
39
$ setPWorLogin ="set password " ;
40
40
}
41
41
42
42
// Load user settings
43
- include (dirname ( __FILE__ ) ."/ " .$ settingsFile );
43
+ include (__DIR__ ."/ " .$ settingsFile );
44
44
45
45
// Remove any previous files that are no longer there
46
46
$ prevFiles =explode (", " ,$ ICEcoderUserSettings ['previousFiles ' ]);
55
55
56
56
// Replace our config created date with the filemtime?
57
57
if (basename ($ _SERVER ['SCRIPT_NAME ' ]) =="index.php " &&$ ICEcoderUserSettings ['configCreateDate ' ] ==0 ) {
58
- $ settingsContents =getData (dirname ( __FILE__ ) ."/ " .$ settingsFile );
58
+ $ settingsContents =getData (__DIR__ ."/ " .$ settingsFile );
59
59
clearstatcache ();
60
- $ configfilemtime =filemtime (dirname ( __FILE__ ) ."/ " ."config___settings.php " );
60
+ $ configfilemtime =filemtime (__DIR__ ."/ " ."config___settings.php " );
61
61
// Make it a number (avoids null, undefined etc)
62
62
$ configfilemtime =intval ($ configfilemtime );
63
63
// Set it to the epoch time now if we don't have a real value
66
66
}
67
67
$ settingsContents =str_replace ('"configCreateDate"=> 0, ' ,'"configCreateDate"=> ' .$ configfilemtime .', ' ,$ settingsContents );
68
68
// Now update the config file
69
- $ fh =fopen (dirname ( __FILE__ ) ."/ " .$ settingsFile ,'w ' )or die ("Can't update config file. Please set public write permissions on " .$ settingsFile ." and press refresh " );
69
+ $ fh =fopen (__DIR__ ."/ " .$ settingsFile ,'w ' )or die ("Can't update config file. Please set public write permissions on " .$ settingsFile ." and press refresh " );
70
70
fwrite ($ fh ,$ settingsContents );
71
71
fclose ($ fh );
72
72
// Set the new value in array
75
75
76
76
// On mismatch of settings file to system, rename to .old and reload
77
77
If ($ ICEcoderUserSettings ["versionNo " ] !=$ ICEcoderSettings ["versionNo " ]) {
78
- rename (dirname ( __FILE__ ) ."/ " .$ settingsFile ,dirname ( __FILE__ ) ."/ " .str_replace (".php " ,".old " ,$ settingsFile ));
78
+ rename (__DIR__ ."/ " .$ settingsFile ,__DIR__ ."/ " .str_replace (".php " ,".old " ,$ settingsFile ));
79
79
header ("Location: settings.php " );
80
80
echo "<script>window.location='settings.php';</script> " ;
81
81
die ('Found old settings file, reloading... ' );
86
86
87
87
// Include language file
88
88
// Load base first as foundation
89
- include (dirname ( __FILE__ ) ."/../lang/ " .basename ($ ICEcoder ['languageBase ' ]));
89
+ include (__DIR__ ."/../lang/ " .basename ($ ICEcoder ['languageBase ' ]));
90
90
$ baseText =$ text ;
91
91
// Load chosen language ontop to replace base
92
- include (dirname ( __FILE__ ) ."/../lang/ " .basename ($ ICEcoder ['languageUser ' ]));
92
+ include (__DIR__ ."/../lang/ " .basename ($ ICEcoder ['languageUser ' ]));
93
93
$ text =array_replace_recursive ($ baseText ,$ text );
94
94
$ _SESSION ['text ' ] =$ text ;
95
95
117
117
$ tDaysRemaining =intval ($ tRemaining /(60 *60 *24 ));
118
118
119
119
// Update this config file?
120
- include (dirname ( __FILE__ ) ."/settings-update.php " );
120
+ include (__DIR__ ."/settings-update.php " );
121
121
122
122
// Set loggedIn and username to false if not set as yet
123
123
if (!isset ($ _SESSION ['loggedIn ' ])) {$ _SESSION ['loggedIn ' ] =false ;};
132
132
$ _SESSION ['username ' ] =$ _POST ['username ' ];
133
133
}
134
134
$ _SESSION ['loggedIn ' ] =true ;
135
- include (dirname ( __FILE__ ) ."/../processes/on-user-login.php " );
135
+ include (__DIR__ ."/../processes/on-user-login.php " );
136
136
header ('Location: ../ ' );
137
137
echo "<script>window.location='../';</script> " ;
138
138
die ('Logging you in... ' );
139
139
}else {
140
- include (dirname ( __FILE__ ) ."/../processes/on-user-login-fail.php " );
140
+ include (__DIR__ ."/../processes/on-user-login-fail.php " );
141
141
}
142
142
};
143
143
184
184
}
185
185
186
186
// Save currently opened files in previousFiles and last10Files arrays
187
- include (dirname ( __FILE__ ) ."/settings-save-current-files.php " );
187
+ include (__DIR__ ."/settings-save-current-files.php " );
188
188
189
189
// Display the plugins
190
- include (dirname ( __FILE__ ) ."/plugins-display.php " );
190
+ include (__DIR__ ."/plugins-display.php " );
191
191
192
192
// If loggedIn is false or we don't have a password set yet and we're not on login screen, boot user to that
193
193
if ((!$ _SESSION ['loggedIn ' ] ||$ ICEcoder ["password " ] =="" ) && !strpos ($ _SERVER ['SCRIPT_NAME ' ],"lib/login.php " )) {
251
251
$ serverAddr ="127.0.0.1 " ;
252
252
}
253
253
$ settingsFileAddr ='config- ' .$ username .str_replace (". " ,"_ " ,$ serverAddr ).'.php ' ;
254
- if (!file_exists (dirname ( __FILE__ ) ."/ " .$ settingsFileAddr )) {
255
- if (!copy (dirname ( __FILE__ ) ."/ " .$ settingsFile ,dirname ( __FILE__ ) ."/ " .$ settingsFileAddr )) {
254
+ if (!file_exists (__DIR__ ."/ " .$ settingsFileAddr )) {
255
+ if (!copy (__DIR__ ."/ " .$ settingsFile ,__DIR__ ."/ " .$ settingsFileAddr )) {
256
256
die ("Couldn't create $ settingsFileAddr. Maybe you need write permissions on the lib folder? " );
257
257
}
258
258
}
259
259
// Disable the enableRegistration config setting if the user had that option chosen
260
260
if (isset ($ _POST ['disableFurtherRegistration ' ])) {
261
- $ updatedConfigSettingsFile =getData (dirname ( __FILE__ ) ."/ " .$ configSettings );
262
- if ($ fUConfigSettings =fopen (dirname ( __FILE__ ) ."/ " .$ configSettings ,'w ' )) {
261
+ $ updatedConfigSettingsFile =getData (__DIR__ ."/ " .$ configSettings );
262
+ if ($ fUConfigSettings =fopen (__DIR__ ."/ " .$ configSettings ,'w ' )) {
263
263
$ updatedConfigSettingsFile =str_replace ('"enableRegistration"=> true ' ,'"enableRegistration"=> false ' ,$ updatedConfigSettingsFile );
264
264
fwrite ($ fUConfigSettings ,$ updatedConfigSettingsFile );
265
265
fclose ($ fUConfigSettings );
272
272
$ _SESSION ['username ' ]=$ _POST ['username ' ];
273
273
}
274
274
$ _SESSION ['loggedIn ' ] =true ;
275
- include (dirname ( __FILE__ ) ."/../processes/on-user-new.php " );
275
+ include (__DIR__ ."/../processes/on-user-new.php " );
276
276
// Finally, load again as now this file has changed and auto login
277
277
header ('Location: ../ ' );
278
278
echo "<script>window.location='../';</script> " ;
290
290
// Continue with whatever we're doing
291
291
// ==================================
292
292
}
293
- ?>
293
+ ?>