/** * the main method, execute the code of the class; * @access public */ function Execute() { if (is_object($this->error)) { return $this->error; } if ($this->contentFile != '' && file_exists($this->contentFile) && ($fp = fopen($this->contentFile, 'r'))) { $this->content = fread($fp, filesize($this->contentFile)); fclose($fp); } else { if ($this->contentFile != '') { return new tNG_error('EMAIL_NO_TEMPLATE', array(), array()); } } $email = new KT_Email(); $email->setPriority($this->importance); foreach ($this->attachments as $filename) { $email->addAttachment($filename); } $email->sendEmail($GLOBALS['tNG_email_host'], $GLOBALS['tNG_email_port'], $GLOBALS['tNG_email_user'], $GLOBALS['tNG_email_password'], $this->getFrom(), $this->getTo(), $this->getCc(), $this->getBcc(), $this->getSubject(), $this->getEncoding(), $this->getTextBody(), $this->getHtmlBody()); if ($email->hasError()) { $arr = $email->getError(); return new tNG_error('EMAIL_FAILED', array(''), array($arr[1])); } }
/** * the main method, execute the code of the class; * @access public */ function Execute() { if (is_object($this->error)) { return $this->error; } if ($this->contentFile != '' && file_exists($this->contentFile) && ($fp = fopen($this->contentFile, 'r'))) { $this->content = fread($fp, filesize($this->contentFile)); fclose($fp); } else { if ($this->contentFile != '') { return new tNG_error('EMAIL_NO_TEMPLATE', array(), array()); } } $arrErrors = array(); while (!$this->recordset->EOF) { $GLOBALS["row_" . $this->recordsetName] = $this->recordset->fields; $email = new KT_Email(); $email->setPriority($this->importance); foreach ($this->attachments as $filename) { $email->addAttachment($filename); } $email->sendEmail($GLOBALS['tNG_email_host'], $GLOBALS['tNG_email_port'], $GLOBALS['tNG_email_user'], $GLOBALS['tNG_email_password'], $this->getFrom(), $this->getTo(), $this->getCc(), $this->getBcc(), $this->getSubject(), $this->getEncoding(), $this->getTextBody(), $this->getHtmlBody()); if ($email->hasError()) { $arr = $email->getError(); $arrErrors[] = 'Email to user: <strong>' . $this->getTo() . '</strong> was not sent. Error returned: ' . $arr[1]; } $this->recordset->MoveNext(); } if (count($arrErrors) > 0) { return new tNG_error('EMAIL_FAILED', array(''), array(implode('<br />', $arrErrors))); } }
/** * return the error message * @return string transaction type * @access public */ function getErrorMsg() { $ret_warning = ''; $ret_user = ''; $ret_devel = ''; $errorWasFound = false; for ($i = 0; $i < $this->n; $i++) { list($ret_warning, $ret_user, $ret_devel) = $this->tNGs[$i]->getErrorMsg(); if ($ret_warning != '' || $ret_user != '' || $ret_devel != '') { $errorWasFound = true; break; } } $uniq = uniqid(""); $rethead = ''; //$rethead = '<link href="' . $this->relPath . 'includes/tng/styles/default.css" rel="stylesheet" type="text/css" />' . "\r\n"; //$rethead .= '<script src="' . $this->relPath . 'includes/common/js/base.js" type="text/javascript"></script>' . "\r\n"; //$rethead .= '<script src="' . $this->relPath . 'includes/common/js/utility.js" type="text/javascript"></script>' . "\r\n"; $ret = ''; $txtContent = ""; $txtContent .= "Client IP:\r\n " . $_SERVER['REMOTE_ADDR']; $txtContent .= "\r\n\r\nHost:\r\n " . $_SERVER['HTTP_HOST']; $txtContent .= "\r\n\r\nRequested URI:\r\n " . KT_getFullUri(); $txtContent .= "\r\n\r\nDate:\r\n " . date("Y-m-d H:i:s"); if ($errorWasFound) { if ($ret_warning != '') { $ret .= '<div id="KT_tngwarning">' . $ret_warning . "</div>\r\n"; $txtContent .= "\r\n\r\nWarning:\r\n " . $ret_warning; } if ($ret_user != '') { $ret .= '<div id="KT_tngerror"><label>' . KT_getResource('ERROR_LABEL', 'tNG') . '</label><div>' . $ret_user . '</div></div>' . "\r\n"; $txtContent .= "\r\n\r\n" . KT_getResource('ERROR_LABEL', 'tNG') . "\r\n " . $ret_user; } if ('DEVELOPMENT' == $GLOBALS['tNG_debug_mode']) { $js_err = KT_escapeJS($ret_user); $js_devNotes = KT_escapeJS($ret_devel); $js_os = PHP_OS; $js_webserver = @$_SERVER['SERVER_SOFTWARE']; $js_servermodel = (!file_exists($this->relPath . 'adodb/') ? 'PHP MySQL ' : 'PHP ADODB ') . phpversion(); $js_installation = KT_escapeJS(php_sapi_name()); $js_extensions = KT_escapeJS(var_export(get_loaded_extensions(), true)); $ret = $rethead . $ret; if ($ret_devel != '') { $ret .= '<div id="KT_tngdeverror"><label>Developer Details:</label><div>' . $ret_devel . '</div></div>'; } $tmp = tNG_log::getResult('html', '_' . $uniq); $ret .= '<div id="KT_tngtrace"><label>tNG Execution Trace - <a href="#" onclick="document.getElementById(\'KT_tngtrace_details_' . $uniq . '\').style.display=(document.getElementById(\'KT_tngtrace_details_' . $uniq . '\').style.display!=\'block\'?\'block\':\'none\'); return false;">VIEW</a></label>' . $tmp . '</div>'; } if ("" != $GLOBALS['tNG_debug_log_type'] && $ret_devel != '') { $txtContent .= "\r\n\r\nDeveloper Details:\r\n " . $ret_devel; $tmp = tNG_log::getResult('text', '_' . $uniq); $txtContent .= "\r\n\r\ntNG Execution Trace:\r\n" . $tmp; if ($GLOBALS['tNG_debug_log_type'] == 'logfile') { // log file $logFile = dirname(realpath(__FILE__)) . "/logs/" . date("Ym") . ".log"; $f = @fopen($logFile, "a"); if ($f) { if (flock($f, LOCK_EX)) { // do an exclusive lock fwrite($f, "=== BEGIN MESSAGE ===\r\n"); fwrite($f, $txtContent); fwrite($f, "=== END MESSAGE ===\r\n"); flock($f, LOCK_UN); // release the lock } fclose($f); } } else { $email = new KT_Email(); //$email->setPriority("medium"); $email->sendEmail($GLOBALS['tNG_email_host'], $GLOBALS['tNG_email_port'], $GLOBALS['tNG_email_user'], $GLOBALS['tNG_email_password'], $GLOBALS['tNG_debug_email_from'], $GLOBALS['tNG_debug_email_to'], "", "", $GLOBALS['tNG_debug_email_subject'], "ISO-8859-1", $txtContent, ""); } } } return $ret; }
/** * the main method, execute the code of the class; * @access public */ function Execute() { $this->searchCss(); if ($this->encoding == '') { $this->encoding = 'iso-8859-1'; } $email = new KT_Email(); $email->setPriority($this->importance); foreach ($this->attachments as $filename) { $email->addAttachment($filename); } $email->sendEmail($GLOBALS['tNG_email_host'], $GLOBALS['tNG_email_port'], $GLOBALS['tNG_email_user'], $GLOBALS['tNG_email_password'], $this->getFrom(), $this->getTo(), $this->getCc(), $this->getBcc(), $this->getSubject(), $this->getEncoding(), $this->getTextBody(), $this->getHtmlBody()); if ($email->hasError()) { $arr = $email->getError(); return new tNG_error('EMAIL_FAILED', array(''), array($arr[1])); } }