3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 die("This script is disabled because it is dangerous. If you need it, please duplicate it elsewhere and provide your own secure workflow. This example file will be removed in the future.");
30 // TIP: If/when we do delete this file, take care to affirmatively check for
31 // deletion as part of the status-check infrastructure. Some upgrade workflows
32 // don't clear out old files properly, and there's no telling the history
33 // of upgrades that have been performed.
38 * @copyright CiviCRM LLC (c) 2004-2016
41 define('CRM_ENCRYPT', 1);
42 define('CRM_SETNULL', 2);
43 function encryptDB() {
45 'civicrm_contact' => array(
46 'first_name' => CRM_ENCRYPT
,
47 'last_name' => CRM_ENCRYPT
,
48 'organization_name' => CRM_ENCRYPT
,
49 'household_name' => CRM_ENCRYPT
,
50 'sort_name' => CRM_ENCRYPT
,
51 'display_name' => CRM_ENCRYPT
,
52 'legal_name' => CRM_ENCRYPT
,
54 'civicrm_address' => array(
55 'street_address' => CRM_ENCRYPT
,
56 'supplemental_address_1' => CRM_ENCRYPT
,
57 'supplemental_address_2' => CRM_ENCRYPT
,
58 'city' => CRM_ENCRYPT
,
59 'postal_code' => CRM_SETNULL
,
60 'postal_code_suffix' => CRM_SETNULL
,
61 'geo_code_1' => CRM_SETNULL
,
62 'geo_code_2' => CRM_SETNULL
,
64 'civicrm_website' => array(
67 'civicrm_email' => array(
68 'email' => CRM_ENCRYPT
,
70 'civicrm_phone' => array(
71 'phone' => CRM_ENCRYPT
,
75 foreach ($tables as $tableName => $fields) {
77 foreach ($fields as $fieldName => $action) {
78 if ($action == CRM_ENCRYPT
) {
79 $clauses[] = "$fieldName = md5($fieldName)";
81 elseif ($action == CRM_SETNULL
) {
82 $clauses[] = "$fieldName = null";
86 if (!empty($clauses)) {
87 $clause = implode(',', $clauses);
88 $query = "UPDATE $tableName SET $clause";
89 CRM_Core_DAO
::executeQuery($query);
97 require_once '../civicrm.config.php';
98 require_once 'CRM/Core/Config.php';
99 $config = CRM_Core_Config
::singleton();
101 // this does not return on failure
102 CRM_Utils_System
::authenticateScript(TRUE);
103 if (!CRM_Core_Permission
::check('administer CiviCRM')) {
104 CRM_Utils_System
::authenticateAbort("User does not have required permission (administer CiviCRM).\n", TRUE);