1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\System; |
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: | class Settings extends AbstractSettings |
79: | { |
80: | protected function initDefaults() |
81: | { |
82: | $this->aContainer = [ |
83: | 'LicenseKey' => new SettingsProperty( |
84: | '', |
85: | 'string', |
86: | null, |
87: | 'License key is supplied here' |
88: | ), |
89: | |
90: | 'AdminLogin' => new SettingsProperty( |
91: | 'superadmin', |
92: | 'string', |
93: | null, |
94: | 'Administrative login' |
95: | ), |
96: | 'AdminPassword' => new SettingsProperty( |
97: | '', |
98: | 'string', |
99: | null, |
100: | 'Administrative password (empty by default)' |
101: | ), |
102: | 'AdminLanguage' => new SettingsProperty( |
103: | 'English', |
104: | 'string', |
105: | null, |
106: | 'Admin interface language' |
107: | ), |
108: | |
109: | 'DBType' => new SettingsProperty( |
110: | Enums\DbType::MySQL, |
111: | 'spec', |
112: | Enums\DbType::class, |
113: | 'Database engine used. Currently, only MySQL is supported' |
114: | ), |
115: | 'DBPrefix' => new SettingsProperty( |
116: | 'au_', |
117: | 'string', |
118: | null, |
119: | 'Prefix used for database tables names' |
120: | ), |
121: | 'DBHost' => new SettingsProperty( |
122: | '127.0.0.1', |
123: | 'string', |
124: | null, |
125: | 'Denotes hostname or socket path used for connecting to SQL database' |
126: | ), |
127: | 'DBName' => new SettingsProperty( |
128: | '', |
129: | 'string', |
130: | null, |
131: | 'The name of database in SQL server used' |
132: | ), |
133: | 'DBLogin' => new SettingsProperty( |
134: | 'root', |
135: | 'string', |
136: | null, |
137: | 'Login for SQL user' |
138: | ), |
139: | 'DBPassword' => new SettingsProperty( |
140: | '', |
141: | 'string', |
142: | null, |
143: | 'Password to access SQL database' |
144: | ), |
145: | |
146: | 'UseSlaveConnection' => new SettingsProperty( |
147: | false, |
148: | 'bool', |
149: | null, |
150: | 'Set of parameters for separate read/write access to the database. If set to true, the first set of credentials will be used to write to the database while Slave credentials - to read from it' |
151: | ), |
152: | 'DBSlaveHost' => new SettingsProperty( |
153: | '127.0.0.1', |
154: | 'string', |
155: | null, |
156: | 'Slave database hostname or socket path' |
157: | ), |
158: | 'DBSlaveName' => new SettingsProperty( |
159: | '', |
160: | 'string', |
161: | null, |
162: | 'Slave database name' |
163: | ), |
164: | 'DBSlaveLogin' => new SettingsProperty( |
165: | 'root', |
166: | 'string', |
167: | null, |
168: | 'Slave database login' |
169: | ), |
170: | 'DBSlavePassword' => new SettingsProperty( |
171: | '', |
172: | 'string', |
173: | null, |
174: | 'Slave database password' |
175: | ), |
176: | 'DBUseExplain' => new SettingsProperty( |
177: | false, |
178: | 'bool', |
179: | null, |
180: | 'Use EXPLAIN in SQL queries' |
181: | ), |
182: | 'DBUseExplainExtended' => new SettingsProperty( |
183: | false, |
184: | 'bool', |
185: | null, |
186: | 'Use Extended EXPLAIN' |
187: | ), |
188: | 'DBLogQueryParams' => new SettingsProperty( |
189: | false, |
190: | 'bool', |
191: | null, |
192: | 'If enabled, parameters values will be recorded in the logs' |
193: | ), |
194: | 'DBDebugBacktraceLimit' => new SettingsProperty( |
195: | false, |
196: | 'bool', |
197: | null, |
198: | 'This parameter can be used to limit the number of stack frames returned' |
199: | ), |
200: | |
201: | 'EnableLogging' => new SettingsProperty( |
202: | false, |
203: | 'bool', |
204: | null, |
205: | 'Activates debug logging' |
206: | ), |
207: | 'EnableEventLogging' => new SettingsProperty( |
208: | false, |
209: | 'bool', |
210: | null, |
211: | 'Activates user activity logging' |
212: | ), |
213: | 'LoggingLevel' => new SettingsProperty( |
214: | Enums\LogLevel::Full, |
215: | 'spec', |
216: | Enums\LogLevel::class, |
217: | 'For debug logs, verbosity level can be set to Full, Warning or Error' |
218: | ), |
219: | 'LogFileName' => new SettingsProperty( |
220: | 'log-{Y-m-d}.txt', |
221: | 'string', |
222: | null, |
223: | 'Denotes log filename pattern' |
224: | ), |
225: | 'LogCustomFullPath' => new SettingsProperty( |
226: | '', |
227: | 'string', |
228: | null, |
229: | 'Allows for overriding log files location' |
230: | ), |
231: | 'LogPostView' => new SettingsProperty( |
232: | false, |
233: | 'bool', |
234: | null, |
235: | 'Determines whether to log full POST data or just key names' |
236: | ), |
237: | |
238: | 'EnableMultiChannel' => new SettingsProperty( |
239: | false, |
240: | 'bool', |
241: | null, |
242: | 'Reserved for future use' |
243: | ), |
244: | 'EnableMultiTenant' => new SettingsProperty( |
245: | false, |
246: | 'bool', |
247: | null, |
248: | 'Enables multi tenant support' |
249: | ), |
250: | 'TenantGlobalCapa' => new SettingsProperty( |
251: | '', |
252: | 'string', |
253: | null, |
254: | 'Reserved for future use' |
255: | ), |
256: | |
257: | 'AllowThumbnail' => new SettingsProperty( |
258: | true, |
259: | 'bool', |
260: | null, |
261: | 'If disabled, image thumbnails will not be generated' |
262: | ), |
263: | 'ThumbnailMaxFileSizeMb' => new SettingsProperty( |
264: | 5, |
265: | 'int', |
266: | null, |
267: | 'Denotes a max filesize of images thumbnails are generated for, in Mbytes' |
268: | ), |
269: | 'CacheCtrl' => new SettingsProperty( |
270: | true, |
271: | 'bool', |
272: | null, |
273: | 'If true, content of mail message opened in a new browser tab will be retrieved from cache' |
274: | ), |
275: | 'CacheLangs' => new SettingsProperty( |
276: | true, |
277: | 'bool', |
278: | null, |
279: | 'Enables caching language files' |
280: | ), |
281: | 'CacheTemplates' => new SettingsProperty( |
282: | true, |
283: | 'bool', |
284: | null, |
285: | 'Enables caching template files' |
286: | ), |
287: | 'DisplayServerErrorInformation' => new SettingsProperty( |
288: | true, |
289: | 'bool', |
290: | null, |
291: | 'If enabled, error messages will include texts returned from the server' |
292: | ), |
293: | 'EnableImap4PlainAuth' => new SettingsProperty( |
294: | false, |
295: | 'bool', |
296: | null, |
297: | 'Reserved for future use' |
298: | ), |
299: | 'RedirectToHttps' => new SettingsProperty( |
300: | false, |
301: | 'bool', |
302: | null, |
303: | 'If enabled, users will automatically be redirected from HTTP to HTTPS' |
304: | ), |
305: | 'SocketConnectTimeoutSeconds' => new SettingsProperty( |
306: | 20, |
307: | 'int', |
308: | null, |
309: | 'Socket connection timeout limit, in seconds' |
310: | ), |
311: | 'SocketGetTimeoutSeconds' => new SettingsProperty( |
312: | 20, |
313: | 'int', |
314: | null, |
315: | 'Socket stream access timeout, in seconds' |
316: | ), |
317: | 'SocketVerifySsl' => new SettingsProperty( |
318: | false, |
319: | 'bool', |
320: | null, |
321: | 'Enables SSL certificate checks' |
322: | ), |
323: | 'UseAppMinJs' => new SettingsProperty( |
324: | true, |
325: | 'bool', |
326: | null, |
327: | 'Enables loading minified JS files (default behavior)' |
328: | ), |
329: | 'XFrameOptions' => new SettingsProperty( |
330: | '', |
331: | 'string', |
332: | null, |
333: | 'If set to SAMEORIGIN, disallows embedding product interface into IFrame to prevent from clickjacking attacks' |
334: | ), |
335: | 'AllowCrossDomainRequestsFromOrigin' => new SettingsProperty( |
336: | '', |
337: | 'string', |
338: | null, |
339: | 'Allows cross-domain requests and handles OPTIONS requests from specified origin. To allow request from any origin use *' |
340: | ), |
341: | 'RemoveOldLogs' => new SettingsProperty( |
342: | true, |
343: | 'bool', |
344: | null, |
345: | 'If enabled, logs older than RemoveOldLogsDays days are automatically removed' |
346: | ), |
347: | 'RemoveOldLogsDays' => new SettingsProperty( |
348: | 2, |
349: | 'int', |
350: | null, |
351: | 'Value for use with RemoveOldLogs setting' |
352: | ), |
353: | 'LogStackTrace' => new SettingsProperty( |
354: | false, |
355: | 'bool', |
356: | null, |
357: | 'If enabled, logs will contain full stack trace of exceptions; disabled by default to prevent logs from containing sensitive data' |
358: | ), |
359: | 'ExpireUserSessionsBeforeTimestamp' => new SettingsProperty( |
360: | 0, |
361: | 'int', |
362: | null, |
363: | 'If set, all user sessions prior to this timestamp will be considered expired' |
364: | ), |
365: | |
366: | 'PasswordMinLength' => new SettingsProperty( |
367: | 0, |
368: | 'int', |
369: | null, |
370: | 'Used by password change modules, if set to non-zero, denotes minimal length of new password' |
371: | ), |
372: | 'PasswordMustBeComplex' => new SettingsProperty( |
373: | false, |
374: | 'bool', |
375: | null, |
376: | 'Used by password change modules, if set to true, new password has to include at least one digit and at least one non-alphanumeric character' |
377: | ), |
378: | |
379: | 'StoreAuthTokenInDB' => new SettingsProperty( |
380: | false, |
381: | 'bool', |
382: | null, |
383: | 'If enabled, authentication tokens will be stored in the database and can be revoked' |
384: | ), |
385: | 'AuthTokenExpirationLifetimeDays' => new SettingsProperty( |
386: | 0, |
387: | 'int', |
388: | null, |
389: | 'If set to non-zero value, means auth tokens will expire after this number of days. 0 means the feature is disabled.' |
390: | ), |
391: | ]; |
392: | } |
393: | |
394: | |
395: | |
396: | |
397: | public function Load($bForceLoad = false) |
398: | { |
399: | $this->initDefaults(); |
400: | if (!\file_exists($this->sPath)) { |
401: | $this->Save(); |
402: | } |
403: | |
404: | return parent::Load($bForceLoad); |
405: | } |
406: | |
407: | public function SyncConfigs() |
408: | { |
409: | $this->initDefaults(); |
410: | $aContainer = $this->aContainer; |
411: | if (!\file_exists($this->sPath)) { |
412: | $this->Save(); |
413: | } |
414: | parent::Load(true); |
415: | $this->aContainer = \array_merge( |
416: | $aContainer, |
417: | $this->aContainer |
418: | ); |
419: | $this->Save(); |
420: | } |
421: | |
422: | public function Save($bBackupConfigFile = true) |
423: | { |
424: | $result = parent::Save($bBackupConfigFile); |
425: | if ($result) { |
426: | Api::CreateContainer(true); |
427: | } |
428: | return $result; |
429: | } |
430: | } |
431: | |