initialize(); CRM_Utils_System::authenticateScript(TRUE); //log the execution of script CRM_Core_Error::debug_log_message('CiviReportMail.php'); } function initialize() { require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); } function run() { require_once 'CRM/Core/Lock.php'; $lock = new CRM_Core_Lock('CiviReportMail'); if ($lock->isAcquired()) { // try to unset any time limits if (!ini_get('safe_mode')) { set_time_limit(0); } // if there are named sets of settings, use them - otherwise use the default (null) require_once 'CRM/Report/Utils/Report.php'; $result = CRM_Report_Utils_Report::processReport(); echo $result['messages']; } else { throw new Exception('Could not acquire lock, another CiviReportMail process is running'); } $lock->release(); } } session_start(); $obj = new CiviReportMail; $obj->run();