Ejemplo n.º 1
0
/**
 * Get redacted settings.
 *
 * @return array
 * @throws CiviCRM_API3_Exception
 */
function _civicrm_api3_system_get_redacted_settings()
{
    static $whitelist = NULL;
    if ($whitelist === NULL) {
        $whitelist = _civicrm_api3_system_get_whitelist(__DIR__ . '/System/setting-whitelist.txt');
    }
    $apiResult = civicrm_api3('Setting', 'get', array());
    $result = array();
    foreach ($apiResult['values'] as $settings) {
        foreach ($settings as $key => $value) {
            if (in_array($key, $whitelist)) {
                $result[$key] = $value;
            }
        }
    }
    return $result;
}
Ejemplo n.º 2
0
/**
 * Generate ae sanitized/anonymized/redacted dump of MySQL configuration.
 *
 * @return array
 * @see _civicrm_api3_system_get_redacted_ini
 */
function _civicrm_api3_system_get_redacted_mysql()
{
    static $whitelist = NULL;
    if ($whitelist === NULL) {
        $whitelist = _civicrm_api3_system_get_whitelist(__DIR__ . '/System/mysql-whitelist.txt');
    }
    $inis = ini_get_all(NULL, FALSE);
    $result = array();
    $dao = CRM_Core_DAO::executeQuery('SHOW VARIABLES');
    while ($dao->fetch()) {
        if (empty($dao->Variable_name) || in_array($dao->Variable_name, $whitelist)) {
            $result[$dao->Variable_name] = $dao->Value;
        } else {
            $result[$dao->Variable_name] = 'REDACTED';
        }
    }
    return $result;
}