本文整理汇总了PHP中Misc::getHostName方法的典型用法代码示例。如果您正苦于以下问题:PHP Misc::getHostName方法的具体用法?PHP Misc::getHostName怎么用?PHP Misc::getHostName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Misc
的用法示例。
在下文中一共展示了Misc::getHostName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendSystemMail
static function sendSystemMail($subject, $body, $attachments = NULL)
{
if ($subject == '' or $body == '') {
return FALSE;
}
//Only send errors to TimeTrex support, not the customer.
$cc = NULL;
$to = 'errors@timetrex.com';
$from = APPLICATION_NAME . '@' . Misc::getHostName(FALSE);
$headers = array('From' => $from, 'Subject' => $subject, 'cc' => $cc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
$mail = new TTMail();
$mail->setTo($to);
$mail->setHeaders($headers);
//$mail->setBody( $body );
@$mail->getMIMEObject()->setTXTBody($body);
if (is_array($attachments)) {
foreach ($attachments as $attachment) {
if (isset($attachment['data']) and isset($attachment['mime_type']) and isset($attachment['file_name'])) {
@$mail->getMIMEObject()->addAttachment($attachment['data'], $attachment['mime_type'], $attachment['file_name'], FALSE);
}
}
}
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
$retval = $mail->Send();
return $retval;
}
示例2: scheduleFooter
function scheduleFooter()
{
global $config_vars;
$margins = $this->pdf->getMargins();
//Don't scale footer text lines as they aren't that important anyways.
$this->pdf->SetFont($this->config['other']['default_font'], '', 8);
//Save x,y and restore after footer is set.
$x = $this->pdf->getX();
$y = $this->pdf->getY();
//Jump to end of page.
if ($this->pdf->getPageHeight() - $margins['bottom'] - $margins['top'] - 15 > $y) {
$this->pdf->setY($this->pdf->getPageHeight() - $margins['bottom'] - $margins['top'] - 15);
}
$company_obj = $this->getUserObject()->getCompanyObject();
if (is_object($company_obj) and $company_obj->getProductEdition() > 10) {
if ($config_vars['other']['force_ssl'] == 1) {
$protocol = 'https';
} else {
$protocol = 'http';
}
$url = $protocol . '://' . Misc::getHostName() . Environment::getBaseURL() . 'ical/ical.php';
$this->pdf->Cell($this->pdf->getPageWidth() - $margins['right'] - $margins['left'], 5, TTi18n::getText('Synchronize this schedule to your desktop/mobile phone calendar application') . ': ' . $url, 1, 0, 'C', 0, NULL, 1);
$this->pdf->Ln();
}
$this->pdf->SetFont($this->config['other']['default_font'], '', 8);
$this->pdf->Cell($this->pdf->getPageWidth() - $margins['right'], 5, TTi18n::getText('Page') . ' ' . $this->pdf->PageNo() . ' of ' . $this->pdf->getAliasNbPages(), 0, 0, 'C', 0);
$this->pdf->Ln();
$this->pdf->SetFont($this->config['other']['default_font'], '', 6);
$this->pdf->Cell($this->pdf->getPageWidth() - $margins['right'], 5, TTi18n::gettext('Report Generated By') . ' ' . APPLICATION_NAME . ' v' . APPLICATION_VERSION . ' @ ' . TTDate::getDate('DATE+TIME', $this->start_time), 0, 0, 'C', 0);
$this->pdf->setX($x);
$this->pdf->setY($y);
return TRUE;
}
示例3: emailMessage
function emailMessage()
{
Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
$email_to_arr = $this->getEmailMessageAddresses();
if ($email_to_arr == FALSE) {
return FALSE;
}
//Get from User Object so we can include more information in the message.
if (is_object($this->getFromUserObject())) {
$u_obj = $this->getFromUserObject();
} else {
Debug::Text('From object does not exist: ' . $this->getFromUserID(), __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
$from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
global $current_user, $config_vars;
if (is_object($current_user) and $current_user->getWorkEmail() != '') {
$reply_to = $current_user->getWorkEmail();
}
Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
$to = array_shift($email_to_arr);
Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
if (is_array($email_to_arr) and count($email_to_arr) > 0) {
$bcc = implode(',', $email_to_arr);
} else {
$bcc = NULL;
}
Debug::Text('Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
//Define subject/body variables here.
$search_arr = array('#from_employee_first_name#', '#from_employee_last_name#', '#from_employee_default_branch#', '#from_employee_default_department#', '#from_employee_group#', '#from_employee_title#', '#company_name#', '#link#');
$replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL);
$email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
$email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
$email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
$email_body .= $this->getSubject() != '' ? TTi18n::gettext('Subject') . ': ' . $this->getSubject() . "\n" : NULL;
$email_body .= TTi18n::gettext('From') . ': #from_employee_first_name# #from_employee_last_name#' . "\n";
$email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #from_employee_default_branch#' . "\n" : NULL;
$email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #from_employee_default_department#' . "\n" : NULL;
$email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #from_employee_group#' . "\n" : NULL;
$email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #from_employee_title#' . "\n" : NULL;
$email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
$email_body .= $replace_arr[6] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
//Always put at the end
$subject = str_replace($search_arr, $replace_arr, $email_subject);
Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
$headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
$body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
$mail = new TTMail();
$mail->setTo($to);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
$retval = $mail->Send();
if ($retval == TRUE) {
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
return TRUE;
}
return TRUE;
//Always return true
}
示例4: emailMessage
function emailMessage()
{
Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
$email_to_arr = $this->getEmailMessageAddresses();
if ($email_to_arr == FALSE) {
return FALSE;
}
$from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
global $current_user, $config_vars;
if (is_object($current_user) and $current_user->getWorkEmail() != '') {
$reply_to = $current_user->getWorkEmail();
}
Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
$to = array_shift($email_to_arr);
Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
if (is_array($email_to_arr) and count($email_to_arr) > 0) {
$bcc = implode(',', $email_to_arr);
} else {
$bcc = NULL;
}
$email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
$email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
$email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
if ($this->getSubject() != '') {
$email_body .= TTi18n::gettext('Subject:') . ' ' . $this->getSubject() . "\n";
}
$protocol = 'http';
if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
$protocol .= 's';
}
$email_body .= TTi18n::gettext('Link') . ': <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::getText('Login') . '</a>';
//Define subject/body variables here.
$search_arr = array('#employee_first_name#', '#employee_last_name#');
$replace_arr = array(NULL, NULL);
$subject = str_replace($search_arr, $replace_arr, $email_subject);
Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
$headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
$body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
$mail = new TTMail();
$mail->setTo($to);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
$retval = $mail->Send();
if ($retval == TRUE) {
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
return TRUE;
}
return TRUE;
//Always return true
}
示例5: emailLog
static function emailLog()
{
if (PRODUCTION === TRUE) {
$output = self::getOutput();
if (strlen($output) > 0) {
$server_domain = Misc::getHostName();
Misc::sendSystemMail(APPLICATION_NAME . ' - Error!', $output);
}
}
return TRUE;
}
示例6: emailException
function emailException($u_obj, $user_date_obj, $punch_obj = NULL, $schedule_obj = NULL, $ep_obj = NULL)
{
global $config_vars;
if (!is_object($u_obj)) {
return FALSE;
}
if (!is_object($user_date_obj)) {
return FALSE;
}
if (!is_object($ep_obj)) {
$ep_obj = $this->getExceptionPolicyObject();
}
//Only email on active exceptions.
if ($this->getType() != 50) {
return FALSE;
}
$email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj);
if ($email_to_arr == FALSE) {
return FALSE;
}
$from = 'DoNotReply@' . Misc::getHostName(FALSE);
$to = array_shift($email_to_arr);
if (is_array($email_to_arr) and count($email_to_arr) > 0) {
$bcc = implode(',', $email_to_arr);
} else {
$bcc = NULL;
}
Debug::Text('To: ' . $to . ' Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
$protocol = 'http';
if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
$protocol .= 's';
}
//Define subject/body variables here.
$search_arr = array('#employee_first_name#', '#employee_last_name#', '#employee_default_branch#', '#employee_default_department#', '#employee_group#', '#employee_title#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#company_name#', '#link#', '#schedule_start_time#', '#schedule_end_time#', '#schedule_branch#', '#schedule_department#', '#punch_time#');
$replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getStartTime()) : NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getEndTime()) : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getBranchObject())) ? $schedule_obj->getBranchObject()->getName() : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getDepartmentObject())) ? $schedule_obj->getDepartmentObject()->getName() : NULL, is_object($punch_obj) ? TTDate::getDate('TIME', $punch_obj->getTimeStamp()) : NULL);
$exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#';
$exception_email_body = TTi18n::gettext('Employee') . ': #employee_first_name# #employee_last_name#' . "\n";
$exception_email_body .= TTi18n::gettext('Date') . ': #date#' . "\n";
$exception_email_body .= TTi18n::gettext('Exception') . ': #exception_name# (#exception_code#)' . "\n";
$exception_email_body .= TTi18n::gettext('Severity') . ': #exception_severity#' . "\n";
$exception_email_body .= ($replace_arr[12] != '' or $replace_arr[13] != '' or $replace_arr[14] != '' or $replace_arr[15] != '' or $replace_arr[16] != '') ? "\n" : NULL;
$exception_email_body .= ($replace_arr[12] != '' and $replace_arr[13] != '') ? TTi18n::gettext('Schedule') . ': #schedule_start_time# - #schedule_end_time#' . "\n" : NULL;
$exception_email_body .= $replace_arr[14] != '' ? TTi18n::gettext('Schedule Branch') . ': #schedule_branch#' . "\n" : NULL;
$exception_email_body .= $replace_arr[15] != '' ? TTi18n::gettext('Schedule Department') . ': #schedule_department#' . "\n" : NULL;
if ($replace_arr[16] != '') {
$exception_email_body .= TTi18n::gettext('Punch') . ': #punch_time#' . "\n";
} elseif ($replace_arr[12] != '' and $replace_arr[13] != '') {
$exception_email_body .= TTi18n::gettext('Punch') . ': ' . TTi18n::gettext('None') . "\n";
}
$exception_email_body .= ($replace_arr[2] != '' or $replace_arr[3] != '' or $replace_arr[4] != '' or $replace_arr[5] != '') ? "\n" : NULL;
$exception_email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #employee_default_branch#' . "\n" : NULL;
$exception_email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #employee_default_department#' . "\n" : NULL;
$exception_email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #employee_group#' . "\n" : NULL;
$exception_email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #employee_title#' . "\n" : NULL;
$exception_email_body .= "\n";
$exception_email_body .= TTi18n::gettext('Link:') . ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
$exception_email_body .= $replace_arr[10] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
//Always put at the end
$exception_email_body .= "\n\n" . TTi18n::gettext('Email sent') . ': ' . TTDate::getDate('DATE+TIME', time()) . "\n";
$subject = str_replace($search_arr, $replace_arr, $exception_email_subject);
//Debug::Text('Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10);
$headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
$body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>';
Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
$mail = new TTMail();
$mail->setTo($to);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
$retval = $mail->Send();
if ($retval == TRUE) {
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception') . ': ' . Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')) . ' To: ' . $to . ' Bcc: ' . $headers['Bcc'], $u_obj->getID(), $this->getTable());
//Make sure this log entry is assigned to the user triggering the exception so it can be viewed in the audit log.
}
return TRUE;
}
示例7: newSession
function newSession($user_id, $client_id = NULL, $ip_address = NULL)
{
global $authentication;
if (is_object($authentication) and $authentication->getSessionID() != '') {
Debug::text('Session ID: ' . $authentication->getSessionID(), __FILE__, __LINE__, __METHOD__, 10);
if ($this->getPermissionObject()->Check('company', 'view') and $this->getPermissionObject()->Check('company', 'login_other_user')) {
if (!is_numeric($user_id)) {
//If username is used, lookup user_id
Debug::Text('Lookup User ID by UserName: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
$ulf = TTnew('UserListFactory');
$ulf->getByUserName(trim($user_id));
if ($ulf->getRecordCount() == 1) {
$user_id = $ulf->getCurrent()->getID();
}
}
$ulf = TTnew('UserListFactory');
$ulf->getByIdAndStatus((int) $user_id, 10);
//Can only switch to Active employees
if ($ulf->getRecordCount() == 1) {
$new_session_user_obj = $ulf->getCurrent();
Debug::Text('Login as different user: ' . $user_id . ' IP Address: ' . $ip_address, __FILE__, __LINE__, __METHOD__, 10);
$new_session_id = $authentication->newSession($user_id, $ip_address);
$retarr = array('session_id' => $new_session_id, 'url' => Misc::getHostName(FALSE) . Environment::getBaseURL());
//Add entry in source *AND* destination user log describing who logged in.
//Source user log, showing that the source user logged in as someone else.
TTLog::addEntry($this->getCurrentUserObject()->getId(), 'Login', TTi18n::getText('Override Login') . ': ' . TTi18n::getText('SourceIP') . ': ' . $authentication->getIPAddress() . ' ' . TTi18n::getText('SessionID') . ': ' . $authentication->getSessionID() . ' ' . TTi18n::getText('To Employee') . ': ' . $new_session_user_obj->getFullName() . '(' . $user_id . ')', $this->getCurrentUserObject()->getId(), 'authentication');
//Destination user log, showing the destination user was logged in *by* someone else.
TTLog::addEntry($user_id, 'Login', TTi18n::getText('Override Login') . ': ' . TTi18n::getText('SourceIP') . ': ' . $authentication->getIPAddress() . ' ' . TTi18n::getText('SessionID') . ': ' . $authentication->getSessionID() . ' ' . TTi18n::getText('By Employee') . ': ' . $this->getCurrentUserObject()->getFullName() . '(' . $user_id . ')', $user_id, 'authentication');
return $this->returnHandler($retarr);
}
}
}
return FALSE;
}
示例8: emailException
function emailException($u_obj, $user_date_obj, $ep_obj = NULL)
{
if (!is_object($u_obj)) {
return FALSE;
}
if (!is_object($user_date_obj)) {
return FALSE;
}
if (!is_object($ep_obj)) {
$ep_obj = $this->getExceptionPolicyObject();
}
//Only email on active exceptions.
if ($this->getType() != 50) {
return FALSE;
}
$email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj);
if ($email_to_arr == FALSE) {
return FALSE;
}
$from = 'DoNotReply@' . Misc::getHostName(FALSE);
$to = array_shift($email_to_arr);
Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
if (is_array($email_to_arr) and count($email_to_arr) > 0) {
$bcc = implode(',', $email_to_arr);
} else {
$bcc = NULL;
}
$exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#';
$exception_email_body = TTi18n::gettext('Employee:') . ' #employee_first_name# #employee_last_name#' . "\n";
$exception_email_body .= TTi18n::gettext('Date:') . ' #date#' . "\n";
$exception_email_body .= TTi18n::gettext('Exception:') . ' #exception_name# (#exception_code#)' . "\n";
$exception_email_body .= TTi18n::gettext('Severity:') . ' #exception_severity#' . "\n";
$exception_email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
//Define subject/body variables here.
$search_arr = array('#employee_first_name#', '#employee_last_name#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#link#');
$replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), NULL);
//For some reason the EOL defaults to \r\n, which seems to screw with Amavis
if (!defined('MAIL_MIMEPART_CRLF')) {
define('MAIL_MIMEPART_CRLF', "\n");
}
$subject = str_replace($search_arr, $replace_arr, $exception_email_subject);
Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
$headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
Debug::Arr($headers, 'Headers: ', __FILE__, __LINE__, __METHOD__, 10);
$body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>';
Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
$mail = new TTMail();
$mail->setTo($to);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
$mail->setBody($mail->getMIMEObject()->get());
$retval = $mail->Send();
if ($retval == TRUE) {
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
return TRUE;
}
return TRUE;
}
示例9: sendPasswordResetEmail
function sendPasswordResetEmail()
{
global $config_vars;
if ($this->getHomeEmail() != FALSE or $this->getWorkEmail() != FALSE) {
if ($this->getWorkEmail() != FALSE) {
$primary_email = $this->getWorkEmail();
if ($this->getHomeEmail() != FALSE) {
$secondary_email = $this->getHomeEmail();
} else {
$secondary_email = NULL;
}
} else {
$primary_email = $this->getHomeEmail();
$secondary_email = NULL;
}
$this->setPasswordResetKey(md5(uniqid()));
$this->setPasswordResetDate(time());
$this->Save(FALSE);
if ($config_vars['other']['force_ssl'] == 1) {
$protocol = 'https';
} else {
$protocol = 'http';
}
$subject = APPLICATION_NAME . ' ' . TTi18n::gettext('password reset requested at ') . TTDate::getDate('DATE+TIME', time()) . ' ' . TTi18n::gettext('from') . ' ' . $_SERVER['REMOTE_ADDR'];
$body = '<html><body>';
$body .= TTi18n::gettext('A password reset has been requested for') . ' "' . $this->getUserName() . '", ';
$body .= ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getBaseURL() . 'ForgotPassword.php?action:password_reset=1&key=' . $this->getPasswordResetKey() . '">' . TTi18n::gettext('please click here to reset your password now') . '</a>.';
$body .= '<br><br>';
$body .= TTi18n::gettext('If you did not request your password to be reset, you may ignore this email.');
$body .= '<br><br>';
$body .= '--<br>';
$body .= APPLICATION_NAME;
$body .= '</body></html>';
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Employee Password Reset By') . ': ' . $_SERVER['REMOTE_ADDR'] . ' ' . TTi18n::getText('Key') . ': ' . $this->getPasswordResetKey(), NULL, $this->getTable());
$headers = array('From' => '"' . APPLICATION_NAME . ' - ' . TTi18n::gettext('Password Reset') . '"<DoNotReply@' . Misc::getHostName(FALSE) . '>', 'Subject' => $subject, 'Cc' => $secondary_email);
$mail = new TTMail();
$mail->setTo($primary_email);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
$retval = $mail->Send();
return $retval;
}
return FALSE;
}
示例10: email
function email($output, $report_schedule_obj = NULL)
{
Debug::Text('Emailing report...', __FILE__, __LINE__, __METHOD__, 10);
if (is_array($output) and isset($output['data']) and $output['data'] != '' and is_object($this->getUserObject()) and ($this->getUserObject()->getHomeEmail() != FALSE or $this->getUserObject()->getWorkEmail() != FALSE)) {
if ($this->getUserObject()->getWorkEmail() != FALSE) {
$primary_email = $this->getUserObject()->getWorkEmail();
$secondary_email = NULL;
if (is_object($report_schedule_obj) and $report_schedule_obj->getEnableHomeEmail() == TRUE and $this->getUserObject()->getHomeEmail() != FALSE) {
$secondary_email .= $this->getUserObject()->getHomeEmail();
}
if (is_object($report_schedule_obj) and $report_schedule_obj->getOtherEmail() != '') {
$secondary_email .= ' ' . $report_schedule_obj->getOtherEmail();
}
} else {
$primary_email = $this->getUserObject()->getHomeEmail();
$secondary_email = NULL;
}
Debug::Text('Emailing report to: ' . $primary_email . ' CC: ' . $secondary_email, __FILE__, __LINE__, __METHOD__, 10);
$subject = APPLICATION_NAME . ' ';
$other_config = $this->getOtherConfig();
if (isset($other_config['report_name']) and $other_config['report_name'] != '') {
$subject .= $other_config['report_name'] . ' (';
}
$subject .= $this->title;
if (isset($other_config['report_name']) and $other_config['report_name'] != '') {
$subject .= ')';
}
$body = '<html><body>';
$body .= TTI18n::getText('Report') . ': ' . $this->title . '<br><br>';
$body .= $this->getDescriptionBlock(TRUE);
$body .= '</body></html>';
//Debug::Text('Email Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10);
//Debug::Text('Email Body: '. $body, __FILE__, __LINE__, __METHOD__,10);
TTLog::addEntry(0, 500, TTi18n::getText('Emailing Report') . ': ' . $this->title . ' ' . TTi18n::getText('To') . ': ' . $primary_email, NULL, $this->getTable());
$headers = array('From' => '"' . APPLICATION_NAME . ' - ' . TTi18n::gettext('Reports') . '"<DoNotReply@' . Misc::getHostName(FALSE) . '>', 'Subject' => $subject, 'Cc' => $secondary_email);
$mail = new TTMail();
$mail->setTo($primary_email);
$mail->setHeaders($headers);
@$mail->getMIMEObject()->setHTMLBody($body);
//$mail->getMIMEObject()->addAttachment($output, 'application/pdf', $this->file_name.'.pdf', FALSE, 'base64');
$mail->getMIMEObject()->addAttachment($output['data'], $output['mime_type'], $output['file_name'], FALSE, 'base64');
$mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
return $mail->Send();
}
Debug::Text('No report data to email, or not email address to send them to!', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
示例11: sendPasswordResetEmail
function sendPasswordResetEmail()
{
global $config_vars;
if ($this->getHomeEmail() != FALSE or $this->getWorkEmail() != FALSE) {
if ($this->getWorkEmail() != FALSE) {
$primary_email = $this->getWorkEmail();
if ($this->getHomeEmail() != FALSE) {
$secondary_email = $this->getHomeEmail();
} else {
$secondary_email = NULL;
}
} else {
$primary_email = $this->getHomeEmail();
$secondary_email = NULL;
}
$this->setPasswordResetKey(md5(uniqid()));
$this->setPasswordResetDate(time());
$this->Save(FALSE);
if ($config_vars['other']['force_ssl'] == 1) {
$protocol = 'https';
} else {
$protocol = 'http';
}
$subject = 'Password Reset requested at ' . TTDate::getDate('DATE+TIME', time()) . ' from ' . $_SERVER['REMOTE_ADDR'];
$body = '
<html><body>
If you did not request your password to be reset, you may ignore this email.
<br>
<br>
If you did request the password for ' . $this->getUserName() . ' to be reset,
please click <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getBaseURL() . 'ForgotPassword.php?action:password_reset=null&key=' . $this->getPasswordResetKey() . '">here</a>
</body></html>
';
//Debug::Text('Emailing Report to: '. $this->getUserName() .' Email: '. $primary_email , __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($body, 'Email Report', __FILE__, __LINE__, __METHOD__,10);
//echo "<pre>$body</pre><br>\n";
//$retval = -->liam<--($primary_email, $subject, $body, "MIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\nFrom: \"TimeTrex - Password Reset\"<DoNotReply@".Misc::getHostName().">\nCc: ". $secondary_email ."\n");
//Debug::Text('Mail() result: '. (int)$retval, __FILE__, __LINE__, __METHOD__,10);
TTLog::addEntry($this->getId(), 500, TTi18n::getText('Employee Password Reset By') . ': ' . $_SERVER['REMOTE_ADDR'] . ' ' . TTi18n::getText('Key') . ': ' . $this->getPasswordResetKey(), NULL, $this->getTable());
$headers = array('From' => '"TimeTrex - Password Reset"<DoNotReply@' . Misc::getHostName(FALSE) . ">", 'Subject' => $subject, 'Cc' => $secondary_email, 'MIME-Version' => '1.0', 'Content-type' => 'text/html; charset=iso-8859-1');
$mail = new TTMail();
$mail->setTo($primary_email);
$mail->setHeaders($headers);
$mail->setBody($body);
$retval = $mail->Send();
return $retval;
}
return FALSE;
}
示例12: emailLog
static function emailLog()
{
if (PRODUCTION === TRUE) {
$output = self::getOutput();
if (strlen($output) > 0) {
$server_domain = Misc::getHostName();
mail('root@' . $server_domain, 'TimeTrex - Error!', $output, "From: timetrex@" . $server_domain . "\n");
}
}
return TRUE;
}
示例13: getHostName
static function getHostName()
{
return Misc::getHostName(TRUE);
}