-
Notifications
You must be signed in to change notification settings - Fork 0
/
civicrm.config.php
46 lines (40 loc) · 1.23 KB
/
civicrm.config.php
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
<?php
/**
* Full path to civicrm.settings.php
* This extension tries to find it automatically, if that fails
* set path here.
*/
//define( 'CIVICRM_SETTINGS_PATH', '/full/path/to/civicrm.settings.php');
/**
* Locate civicrm.settings.php configuration file
*/
function find_civi_settings_file(): string
{
// Candidates
$candidates[] = '../../sites/default';
$candidates[] = '../../../sites/default';
$candidates[] = '../../../../sites/default';
$candidates[] = '../../../../../sites/default';
foreach ($candidates as $candidate) {
$settings_file = "${candidate}/civicrm.settings.php";
if (is_dir($candidate) && is_readable($settings_file)) {
return $settings_file;
}
}
// Couldn't find file --> error message & close
http_response_code(500);
echo 'CiviCRM settings file not found';
exit;
}
// Settings file not defined --> search it
if (!defined('CIVICRM_SETTINGS_PATH')) {
$settings_file = find_civi_settings_file();
define('CIVICRM_SETTINGS_PATH', $settings_file);
}
//require_once $settings_file;
$success = include_once CIVICRM_SETTINGS_PATH;
if ($success == false) {
http_response_code(500);
echo 'Could not load the settings.';
exit();
}