3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 class CRM_Utils_Check_Env
{
38 * Run some sanity checks.
40 * @return array<CRM_Utils_Check_Message>
42 public function checkAll() {
43 $messages = array_merge(
44 $this->checkMysqlTime(),
46 $this->checkOutboundMail()
52 * Check that the MySQL time settings match the PHP time settings.
54 * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
56 public function checkMysqlTime() {
59 $phpNow = date('Y-m-d H:i');
60 $sqlNow = CRM_Core_DAO
::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')");
61 if (!CRM_Utils_Time
::isEqual($phpNow, $sqlNow, 2.5 * 60)) {
62 $messages[] = new CRM_Utils_Check_Message(
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(
65 1 => CRM_Utils_System
::getWikiBaseURL() . 'checkMysqlTime',
69 ts('Environment Settings'),
70 \Psr\Log\LogLevel
::ERROR
80 public function checkDebug() {
83 $config = CRM_Core_Config
::singleton();
85 $messages[] = new CRM_Utils_Check_Message(
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'))),
90 \Psr\Log\LogLevel
::WARNING
100 public function checkOutboundMail() {
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
)
109 $messages[] = new CRM_Utils_Check_Message(
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'))),
113 ts('Outbound Email Settings'),
114 \Psr\Log\LogLevel
::WARNING