/** * @param array(CMS_users) $users users to send message to * @param array(CMS_profile_user) $users * @param array($language=>$subject) $messages indexed by languages code * @param array($language=>$subject) $subjects indexed by languages code * @param integer $alertLevel * @return void * @access public */ function setUserMessages($users, $messages, $subjects, $alertLevel = ALERT_LEVEL_VALIDATION, $module = MOD_STANDARD_CODENAME) { $mainURL = CMS_websitesCatalog::getMainURL(); $template = is_file(PATH_MAIL_TEMPLATES_FS) ? PATH_MAIL_TEMPLATES_FS : ''; foreach ($users as $user) { //if is integer create user object if (!is_a($user, "CMS_user_profile") && SensitiveIO::isPositiveInteger($user)) { $user = CMS_profile_usersCatalog::getByID($user); } //if user hasn't alert level for this module or user is not active anymore, skip it if (!$user->hasAlertLevel($alertLevel, $module) || $user->isDeleted() || !$user->isActive()) { //CMS_grandFather::raiseError('user '.$user->getFullName().' has no alerts for level '.$alertLevel.' for module '.$module); continue; } $userLang = $user->getLanguage(); $email = new CMS_email(); if ($user->getEmail()) { if ($email->setEmailTo($user->getEmail())) { $email->setSubject($subjects[$userLang->getCode()], true); $email->setBody($messages[$userLang->getCode()]); $email->setFooter($userLang->getMessage(self::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/"))); $email->setTemplate($template); $this->_messages[] = $email; } else { $this->raiseError("Email Catalog: email invalid (" . $user->getEmail() . ") for user : " . $user->getFullName()); } } } }
$body .= 'User : '******'REMOTE_ADDR'] . "\n\n"; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $body .= 'Browser : ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n"; } $body .= 'Host : ' . $_SERVER['HTTP_HOST'] . ' (' . $_SERVER['SERVER_ADDR'] . ")\n\n"; $body .= 'This email is automaticaly sent from your website. You can stop this sending with the parameter ERROR404 EMAIL ALERT.'; $mail = new CMS_email(); $mail->setSubject("404 Error in " . APPLICATION_LABEL); $mail->setBody($body); $mail->setEmailFrom(APPLICATION_POSTMASTER_EMAIL . "<" . APPLICATION_POSTMASTER_EMAIL . ">"); $mail->setEmailTo(APPLICATION_MAINTAINER_EMAIL); $mainURL = CMS_websitesCatalog::getMainURL(); $cms_language = CMS_languagesCatalog::getByCode('en'); $mail->setFooter($cms_language->getMessage(CMS_emailsCatalog::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/"))); $mail->setTemplate(PATH_MAIL_TEMPLATES_FS); $mail->sendEmail(); } //try to get website by path to serve specific 404 page $path = pathinfo(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), PATHINFO_DIRNAME); $website = null; if ($path && $path != '/') { $websites = CMS_websitesCatalog::getAll('order'); foreach ($websites as $website) { if ($website->getPagesPath(PATH_RELATIVETO_WEBROOT)) { if (strpos($path, $website->getPagesPath(PATH_RELATIVETO_WEBROOT)) === 0 && is_object($website->get404())) { break; } } } }