/** * Performs quoted-printable encoding (this code is from Zend_Mime). * * @param string $str String to be encoded. * @param int $lineLength Line length to wrap. * @param string $lineEnd Line ending. * @return string */ function encodeQuotedPrintable($str, $lineLength = 72, $lineEnd = "\n") { $out = ''; $str = Mail_Simple::_encodeQuotedPrintable($str); // Split encoded text into separate lines while ($str) { $ptr = strlen($str); if ($ptr > $lineLength) { $ptr = $lineLength; } // Ensure we are not splitting across an encoded character $pos = strrpos(substr($str, 0, $ptr), '='); if ($pos !== false && $pos >= $ptr - 2) { $ptr = $pos; } // Check if there is a space at the end of the line and rewind if ($ptr > 0 && $str[$ptr - 1] == ' ') { --$ptr; } // Add string and continue $out .= substr($str, 0, $ptr) . '=' . $lineEnd; $str = substr($str, $ptr); } $out = rtrim($out, $lineEnd); $out = rtrim($out, '='); return $out; }
// Generate the table data. $data = generateTableData($to, $back, $period, null, null, $onlyReName); // Remove archived rows. foreach ($data['groups'] as $gName => $gRows) { foreach ($gRows as $rName => $rInfo) { if ($rInfo['archived']) { unset($data['groups'][$gName][$rName]); } } if (!$data['groups'][$gName]) { unset($data['groups'][$gName]); } } // Generate HTML. $html = generateHtmlTableFromData($data); $firstCaption = current($data['captions']); $SELECT_PERIODS = getPeriods(); $name = getSetting("instance"); $replyto = getSetting("replyto"); $url = getSetting("index_url"); foreach (preg_split('/\\s*,\\s*/s', $emails) as $email) { $email = trim($email); if (!$email) { continue; } ob_start(); template("mail", array("title" => ($name ? $name . ": " : "") . $SELECT_PERIODS[$period] . " stats: " . preg_replace('/\\s+/s', ' ', $firstCaption['caption']) . " [" . date("Y-m-d", $firstCaption['to']) . "]", "to" => $email, "replyto" => $replyto ? $replyto : "*****@*****.**", "url" => $url . "?to=" . date("Y-m-d", $to) . "&period=" . $period, "htmlTable" => $html), true, true); $mail = ob_get_clean(); $mail = preg_replace('{(?=<tr)|(?<=/tr>)}s', "\n", $mail); Mail_Simple::mail($mail); }