Commit | Line | Data |
---|---|---|
1e927c45 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
1e927c45 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
1e927c45 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
1e927c45 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
1e927c45 TO |
32 | * $Id: $ |
33 | * | |
34 | */ | |
35 | class CRM_Utils_Check_Env { | |
36 | ||
37 | /** | |
38 | * Run some sanity checks. | |
39 | * | |
40 | * @return array<CRM_Utils_Check_Message> | |
41 | */ | |
42 | public function checkAll() { | |
43 | $messages = array_merge( | |
7342d7c4 TO |
44 | $this->checkMysqlTime(), |
45 | $this->checkDebug(), | |
46 | $this->checkOutboundMail() | |
1e927c45 TO |
47 | ); |
48 | return $messages; | |
49 | } | |
50 | ||
7342d7c4 TO |
51 | /** |
52 | * Check that the MySQL time settings match the PHP time settings. | |
53 | * | |
54 | * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings | |
55 | */ | |
1e927c45 TO |
56 | public function checkMysqlTime() { |
57 | $messages = array(); | |
58 | ||
59 | $phpNow = date('Y-m-d H:i'); | |
60 | $sqlNow = CRM_Core_DAO::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')"); | |
8010540a | 61 | if (!CRM_Utils_Time::isEqual($phpNow, $sqlNow, 2.5 * 60)) { |
1e927c45 TO |
62 | $messages[] = new CRM_Utils_Check_Message( |
63 | 'checkMysqlTime', | |
64 | ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.<br /><a href="%1">Read more about this warning</a>', array( | |
7342d7c4 | 65 | 1 => CRM_Utils_System::getWikiBaseURL() . 'checkMysqlTime', |
1e927c45 TO |
66 | 2 => $sqlNow, |
67 | 3 => $phpNow, | |
68 | )), | |
7df9b5d5 AH |
69 | ts('Environment Settings'), |
70 | \Psr\Log\LogLevel::ERROR | |
1e927c45 TO |
71 | ); |
72 | } | |
73 | ||
74 | return $messages; | |
75 | } | |
7342d7c4 | 76 | |
5bc392e6 EM |
77 | /** |
78 | * @return array | |
79 | */ | |
7342d7c4 TO |
80 | public function checkDebug() { |
81 | $messages = array(); | |
82 | ||
83 | $config = CRM_Core_Config::singleton(); | |
84 | if ($config->debug) { | |
85 | $messages[] = new CRM_Utils_Check_Message( | |
86 | 'checkDebug', | |
87 | ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.', | |
88 | array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))), | |
7df9b5d5 AH |
89 | ts('Debug Mode'), |
90 | \Psr\Log\LogLevel::WARNING | |
7342d7c4 TO |
91 | ); |
92 | } | |
93 | ||
94 | return $messages; | |
95 | } | |
96 | ||
5bc392e6 EM |
97 | /** |
98 | * @return array | |
99 | */ | |
7342d7c4 TO |
100 | public function checkOutboundMail() { |
101 | $messages = array(); | |
102 | ||
103 | $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); | |
104 | if (($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB | |
105 | || (defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG) | |
106 | || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED | |
107 | || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) | |
108 | ) { | |
109 | $messages[] = new CRM_Utils_Check_Message( | |
110 | 'checkOutboundMail', | |
111 | ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.', | |
112 | array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))), | |
7df9b5d5 AH |
113 | ts('Outbound Email Settings'), |
114 | \Psr\Log\LogLevel::WARNING | |
7342d7c4 TO |
115 | ); |
116 | } | |
117 | ||
118 | return $messages; | |
119 | } | |
96025800 | 120 | |
5bc392e6 | 121 | } |