|
From: OryNider <ory...@us...> - 2007-12-12 18:41:53
|
Update of /cvsroot/mxbb/mx_contact/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3418/includes Added Files: contact_attach.php contact_constants.php contact_emailer.php contact_extend.php functions_contact.php Log Message: First Version! --- NEW FILE: contact_attach.php --- <?php /*************************************************************************** * contact_attach.php * --------------------- * Version: 9.0.0 * Begin: Tuesday, Dec 06, 2006 * Copyright: (C) 2006-07, Marcus * E-mail: ma...@ph... * $id: 18:52 03/07/2007 * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if(!defined('IN_PORTAL')) { die('Hacking Attempt'); } // // Filename Hash option // if($contact_config['contact_hash'] == 0) { // // Normal Filenames // $attachment = !empty($attachment) ? strtolower(urlencode(basename($HTTP_POST_FILES['attachment']['name']))) : ''; $attach = $server_url . $script_path . "/" . trim($contact_config['contact_file_root']) . "/" . decode_ip($user_ip) . "/" . $attachment; } else { // // MD5 Filenames // $upload = strtolower(urlencode(basename($HTTP_POST_FILES['attachment']['name']))); // Get the file extension first $extn = substr(strrchr($upload, "."), 1); // Generate a random Filename $attachment = !empty($attachment) ? strtolower(md5(mt_rand() * time()) . "." . $extn) : ''; $attach = $server_url . $script_path . "/" . trim($contact_config['contact_file_root']) . "/" . decode_ip($user_ip) . "/" . $attachment; } $delete_link = sprintf("\n" . $lang['Remove_file'], $server_url . $script_name . "?delete=" . decode_ip($user_ip) . "/" . $attachment . "\n"); // // Was there an attachment? Yes? Then lets process it. // if(empty($attachment)) { $attach = $lang['Empty']; $delete_link = ''; } else { $filename = basename($HTTP_POST_FILES['attachment']['name']); $ext = strrchr(strtolower($filename), '.'); // // Banned extentions // $blacklist = array( 'adp', 'as', 'asmx', 'asp', 'aspx', 'avi', 'bat', 'bin', 'cfg', 'cgi', 'com', 'cmd', 'css', 'dhtm', 'dhtml', 'dll', 'doc', 'exe', 'fla', 'gvi', 'hta', 'htaccess', 'htm', 'html', 'htt', 'inc', 'ini', 'jar', 'js', 'jse', 'jsp', 'jspx', 'lnk', 'mdb', 'moov', 'mov', 'movie', 'mp3', 'mp4', 'mpa', 'mpe', 'mpeg', 'mpg', 'obs', 'pdf', 'php', 'php3', 'php4', 'php5', 'php6', 'phtm', 'phtml', 'pif', 'pl', 'ppt', 'prg', 'ra', 'ram', 'raw', 'reg', 'rgs', 'rhtml', 'rm', 'rtf', 'scr', 'sct', 'shb', 'shs', 'sht', 'shtm', 'shtml', 'sql', 'sys', 'tlb', 'tpl', 'txt', 'vb', 'vbe', 'vbs', 'vbscript', 'vdo', 'wav', 'ws', 'wsf', 'xls', 'xml' ); // // Permitted extensions // $whitelist = array( 'bmp', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'png', 'psd', 'rar', 'swf', 'tiff', 'zip' ); if(in_array(trim($ext, '.'), $blacklist)) { $CF_illegal_ext = $_br . sprintf($lang['Illegal_ext'], $ext) . "<br />" . $lang['zip_advise']; $CF_general_message = 1; } elseif(!in_array(trim($ext, '.'), $whitelist)) { $CF_unknown_ext = $_br . sprintf($lang['Unknown_ext'], $ext) . "<br />" . $lang['zip_advise']; $CF_general_message = 1; } // Stage 2 error_check(); // // Extension safe - proceed with upload // if(($HTTP_POST_FILES['attachment']['size'] > intval($contact_config['contact_max_file_size'] * 1024)) || ($HTTP_POST_FILES['attachment']['error'] == 1)) { $CF_attach_file_big = $_br . sprintf($lang['Attach-Too_big'], $contact_config['contact_max_file_size']) . "<br />" . $lang['zip_advise']; $CF_general_message = 1; } elseif(($HTTP_POST_FILES['attachment']['error'] == 3) || ($HTTP_POST_FILES['attachment']['error'] == 6)) { $CF_attach_POST_error = $_br . $lang['POST_ERROR']; $CF_general_message = 1; } elseif(($HTTP_POST_FILES['attachment']['size'] == 0) || ($HTTP_POST_FILES['attachment']['error'] == 4)) { $CF_attach_file_dud = $_br . $lang['Attach_dud']; $CF_general_message = 1; } elseif(file_exists(@phpbb_realpath($phpbb_root_path . $contact_config['contact_file_root'] . "/" . decode_ip($user_ip) . "/" . $attachment))) { $CF_attach_file_exists = $_br . $lang['Attach-File_exists']; $CF_general_message = 1; } // Stage 3 error_check(); // // Image Types // $imfilename = basename($HTTP_POST_FILES['attachment']['name']); $image_types = array( 'bmp', 'gif', 'jpg', 'jpeg', 'png', 'tiff', 'swf', 'psd' ); $imext = strrchr(strtolower($imfilename), "."); if(in_array(trim($imext, '.'), $image_types)) { list($width, $height, $type) = @getimagesize($HTTP_POST_FILES['attachment']['tmp_name']); if(intval($width) > 0 && intval($height) > 0) { switch ($type) { // GIF case 1: if($imext != '.gif') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } break; // JPG, JPC, JP2, JPX, JB2 case 2: case 9: case 10: case 11: case 12: if($imext != '.jpg' && $imext != '.jpeg') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } break; // PNG case 3: if($imext != '.png') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } break; // SWF case 4: if($imext != '.swf') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } elseif($imext == '.swf') { $CF_image_zip = $_br . $lang['Image_zip']; $CF_general_message = 1; } break; // PSD case 5: if($imext != '.psd') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } elseif($imext == '.psd') { $CF_image_zip = $_br . $lang['Image_zip']; $CF_general_message = 1; } break; // BMP case 6: if($imext != '.bmp') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } elseif($imext == '.bmp') { $CF_image_zip = $_br . $lang['Image_zip']; $CF_general_message = 1; } break; // TIFF's case 7: case 8: if($imext != '.tiff') { $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } elseif($imext == '.tiff') { $CF_image_zip = $_br . $lang['Image_zip']; $CF_general_message = 1; } break; default: $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } } else { // XSS? $CF_image_error = $_br . $lang['Image_error']; $CF_general_message = 1; } } // Stage 4 error_check(); if(!file_exists(@phpbb_realpath($module_root_path . $contact_config['contact_file_root'] . "/" . decode_ip($user_ip)))) { if(!file_exists(@phpbb_realpath($module_root_path . $contact_config['contact_file_root'] . "/"))) { @mkdir($module_root_path . $contact_config['contact_file_root'] . "/", 0755); $fd = @fopen($module_root_path . $contact_config['contact_file_root'] . "/index.html", 'a'); @fclose($fd); } @mkdir($module_root_path . $contact_config['contact_file_root'] . "/" . decode_ip($user_ip), 0755); } if(@is_uploaded_file($HTTP_POST_FILES['attachment']['tmp_name'])) { @move_uploaded_file($HTTP_POST_FILES['attachment']['tmp_name'], $module_root_path . $contact_config['contact_file_root'] . "/" . decode_ip($user_ip) . "/" . $attachment); $fa = @fopen($module_root_path . $contact_config['contact_file_root'] . "/" . decode_ip($user_ip) . "/index.html", 'a'); @fclose($fa); $CF_attach_success = $_br . $lang['Attach-Uploaded']; } else { @unlink($attach); $CF_attach_POST_error = $_br . $lang['POST_ERROR']; $CF_general_message = 1; } } ?> --- NEW FILE: functions_contact.php --- <?php /*************************************************************************** * functions_contact.php * --------------------- * Version: 9.0.0 * Begin: Tuesday, Dec 06, 2006 * Copyright: (C) 2006-07, Marcus * E-mail: ma...@ph... * $id: 21:55 25/06/2007 * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if(!defined('IN_PORTAL')) { die('Hacking Attempt'); } if(!$userdata['session_logged_in']) { $remove = $HTTP_GET_VARS['delete']; redirect($module_root_path . "login.$phpEx?redirect=index.$phpEx&delete=$remove", true); } elseif($userdata['user_level'] != ADMIN) { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); // lang_main.php } else { $filename = $module_root_path . "/" . trim($contact_config['contact_file_root']) . "/" . $HTTP_GET_VARS['delete']; // // Exploit Prevention // //exploit_catch($filename); // // If filename and location matches okay, delete it.. // if(file_exists($filename)) { delete_file($filename); mx_message_die(GENERAL_MESSAGE, $lang['File_Removed']); } else { mx_message_die(GENERAL_ERROR, $lang['File_Not_Here']); } } function exploit_catch($filename) { $methods = array('..', 'contact.php', '\0'); foreach($methods as $hacks) { if(strpos($filename, $hacks) !== false) { die('Hacking Attempt'); } } if(is_dir($filename)) { die('Hacking Attempt'); } } function delete_file($filename) { global $HTTP_GET_VARS, $db, $contact_config, $module_root_path; @unlink($filename); clearstatcache(); if($contact_config['contact_storage'] == 1) { $filename = $module_root_path . trim($contact_config['contact_file_root']) . "/" . $HTTP_GET_VARS['delete']; $sql = "UPDATE " . CONTACT_MSGS_TABLE . " SET upfile = '' WHERE upfile = '$filename'"; if(!($result = $db->sql_query($sql))) { mx_message_die(GENERAL_ERROR, 'Could not update Contact table', '', __LINE__, __FILE__, $sql); } } } ?> --- NEW FILE: contact_extend.php --- <?php /*************************************************************************** * contact_extend.php * ------------------ * Version: 9.0.0 * Begin: Tuesday, Dec 06, 2006 * Copyright: (C) 2006-07, Marcus * E-mail: ma...@ph... * $id: 21:20 01/06/2007 * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if(!defined('IN_PORTAL')) { die('Hacking Attempt'); } if($contact_config['contact_thankyou'] == 1 && !$userdata['session_logged_in']) { return; } else { if($email == $lang['Empty']) { return; } else { // // Prune expired emails (24hr anti-spam) // $time = time(); $sql = "DELETE FROM " . CONTACT_EMAILS_TABLE . " WHERE lasttime <= '$time'"; $result = $db->sql_query($sql); if(!$db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, 'Failed to update emails', '', __LINE__, __FILE__, $sql); } // // Store new Sender e-mail with limit (3 max) // $sql = "SELECT * FROM " . CONTACT_EMAILS_TABLE . " WHERE email = '$email'"; $result = $db->sql_query($sql); if(!$db->sql_query($sql)) { mx_message_die(CRITICAL_ERROR, 'Could not query email information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if(empty($row['email'])) { $lasttime = time() + intval(24 * 60) * intval(60); $initial = 1; $sql = "INSERT INTO " . CONTACT_EMAILS_TABLE . " (email, sent, lasttime) VALUES ('" . str_replace("\'", "''", $email) . "', $initial, $lasttime)"; if(!$db->sql_query($sql)) { mx_message_die(CRITICAL_ERROR, 'Could not update email information', '', __LINE__, __FILE__, $sql); } } else { if($row['sent'] >= 3) { mx_message_die(GENERAL_ERROR, $lang['Thankyou_limit']); } else { $sql = "UPDATE " . CONTACT_EMAILS_TABLE . " SET sent = sent + 1 WHERE email = '$email'"; if(!$db->sql_query($sql)) { mx_message_die(CRITICAL_ERROR, 'Could not update email information', '', __LINE__, __FILE__, $sql); } } } // // Send a Thank You e-mail to the sender // $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $email_headers = 'X-AntiAbuse: Board Servername - ' . $board_config['server_name'] . "\n"; $email_headers .= 'X-AntiAbuse: User ID - ' . $userdata['user_id'] . "\n"; $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n"; empty($email) ? $emailer->email_address() : $emailer->email_address($email); $emailer->extra_headers($email_headers); $emailer->use_template('contact_thanks', $userdata['user_lang']); $emailer->set_subject($subject); $emailer->assign_vars(array( 'REAL_NAME' => $real_name, 'USERNAME' => $user_name, 'EMAIL' => $email, 'COMMENTS' => $comments, 'USER_IP' => decode_ip($user_ip), 'TIMEDATE' => $timedate, 'SITENAME' => $board_config['sitename']) ); $emailer->send(); $emailer->reset(); } } ?> --- NEW FILE: contact_constants.php --- <?php /** * * @package mxBB Portal Module - mx_contact * @version $Id: contact_constants.php,v 1.1 2007/12/12 18:41:43 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } // ------------------------------------------------------------------------- // Extend User Style with module lang and images // Usage: $mx_user->extend(LANG, IMAGES) // Switches: // - LANG: MX_LANG_MAIN (default), MX_LANG_ADMIN, MX_LANG_ALL, MX_LANG_NONE // - IMAGES: MX_IMAGES (default), MX_IMAGES_NONE // ------------------------------------------------------------------------- $mx_user->extend(MX_LANG_MAIN, MX_IMAGES_NONE); define('CONTACT_TABLE', $mx_table_prefix . 'contact'); define('CONTACT_CONFIG_TABLE', $mx_table_prefix . 'contact_config'); define('CONTACT_MSGS_TABLE', $mx_table_prefix . 'contact_msgs'); define('CONTACT_EMAILS_TABLE', $mx_table_prefix . 'contact_emails'); ?> --- NEW FILE: contact_emailer.php --- <?php /*************************************************************************** contact_emailer.php ------------------- begin : Sunday Aug. 12, 2001 copyright : (C) 2001 The phpBB Group email : su...@ph... $Id: contact_emailer.php,v 1.1 2007/12/12 18:41:43 orynider Exp $ ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ // // The emailer class has support for attaching files, that isn't implemented // in the 2.0 release but we can probable find some way of using it in a future // release // class emailer { var $msg, $subject, $extra_headers; var $addresses, $reply_to, $from; var $use_smtp; var $tpl_msg = array(); function emailer($use_smtp) { $this->reset(); $this->use_smtp = $use_smtp; $this->reply_to = $this->from = ''; } // Resets all the data (address, template file, etc etc to default function reset() { $this->addresses = array(); $this->vars = $this->msg = $this->extra_headers = ''; } // Sets an email address to send to function email_address($address) { $this->addresses['to'] = trim($address); } function cc($address) { $this->addresses['cc'][] = trim($address); } function bcc($address) { $this->addresses['bcc'][] = trim($address); } function replyto($address) { $this->reply_to = trim($address); } function from($address) { $this->from = trim($address); } // set up subject for mail function set_subject($subject = '') { $this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject)); } // set up extra mail headers function extra_headers($headers) { $this->extra_headers .= trim($headers) . "\n"; } function use_template($template_file, $template_lang = '') { global $board_config, $phpbb_root_path, $module_root_path, $mx_root_path; if (trim($template_file) == '') { mx_message_die(GENERAL_ERROR, 'No template file set', '', __LINE__, __FILE__); } if (trim($template_lang) == '') { $template_lang = $board_config['default_lang']; } if (empty($this->tpl_msg[$template_lang . $template_file])) { $tpl_file = $module_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl'; if (!@file_exists(@phpbb_realpath($tpl_file))) { $tpl_file = $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/email/' . $template_file . '.tpl'; if (!@file_exists(@phpbb_realpath($tpl_file))) { mx_message_die(GENERAL_ERROR, 'Could not find email template file :: ' . $template_file . ' @:' . $tpl_file, '', __LINE__, __FILE__); } } if (!($fd = @fopen($tpl_file, 'r'))) { mx_message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $template_file . ' @:' . $tpl_file, '', __LINE__, __FILE__); } $this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file)); fclose($fd); } $this->msg = $this->tpl_msg[$template_lang . $template_file]; return true; } // assign variables function assign_vars($vars) { $this->vars = (empty($this->vars)) ? $vars : $this->vars . $vars; } // Send the mail out to the recipients set previously in var $this->address function send() { global $board_config, $lang, $phpEx, $phpbb_root_path, $db; // Escape all quotes, else the eval will fail. $this->msg = str_replace ("'", "\'", $this->msg); $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->msg); // Set vars reset ($this->vars); while (list($key, $val) = each($this->vars)) { $$key = $val; } eval("\$this->msg = '$this->msg';"); // Clear vars reset ($this->vars); while (list($key, $val) = each($this->vars)) { unset($$key); } // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable $drop_header = ''; $match = array(); if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) { $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject'); $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); } else { $this->subject = (($this->subject != '') ? $this->subject : 'No Subject'); } if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match)) { $this->encoding = (trim($match[2]) != '') ? trim($match[2]) : trim($lang['ENCODING']); $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); } else { $this->encoding = trim($lang['ENCODING']); } if ($drop_header != '') { $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); } $to = $this->addresses['to']; $cc = (count($this->addresses['cc'])) ? implode(', ', $this->addresses['cc']) : ''; $bcc = (count($this->addresses['bcc'])) ? implode(', ', $this->addresses['bcc']) : ''; // Build header $this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : ''); // Send message ... removed $this->encode() from subject for time being if ( $this->use_smtp ) { if ( !defined('SMTP_INCLUDED') ) { include($phpbb_root_path . 'includes/smtp.' . $phpEx); } $result = smtpmail($to, $this->subject, $this->msg, $this->extra_headers); } else { $empty_to_header = ($to == '') ? TRUE : FALSE; $to = ($to == '') ? (($board_config['sendmail_fix']) ? ' ' : 'Undisclosed-recipients:;') : $to; $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers); if (!$result && !$board_config['sendmail_fix'] && $empty_to_header) { $to = ' '; $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '1' WHERE config_name = 'sendmail_fix'"; if (!$db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, 'Unable to update config table', '', __LINE__, __FILE__, $sql); } $board_config['sendmail_fix'] = 1; $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers); } } // Did it work? if (!$result) { mx_message_die(GENERAL_ERROR, 'Failed sending email :: ' . (($this->use_smtp) ? 'SMTP' : 'PHP') . ' :: ' . $result, '', __LINE__, __FILE__); } return true; } // Encodes the given string for proper display for this encoding ... nabbed // from php.net and modified. There is an alternative encoding method which // may produce lesd output but it's questionable as to its worth in this // scenario IMO function encode($str) { if ($this->encoding == '') { return $str; } // define start delimimter, end delimiter and spacer $end = "?="; $start = "=?$this->encoding?B?"; $spacer = "$end\r\n $start"; // determine length of encoded text within chunks and ensure length is even $length = 75 - strlen($start) - strlen($end); $length = floor($length / 2) * 2; // encode the string and split it into chunks with spacers after each chunk $str = chunk_split(base64_encode($str), $length, $spacer); // remove trailing spacer and add start and end delimiters $str = preg_replace('#' . preg_quote($spacer, '#') . '$#', '', $str); return $start . $str . $end; } // // Attach files via MIME. // function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay) { global $lang; $mime_boundary = "--==================_846811060==_"; $this->msg = '--' . $mime_boundary . "\nContent-Type: text/plain;\n\tcharset=\"" . $lang['ENCODING'] . "\"\n\n" . $this->msg; if ($mime_filename) { $filename = $mime_filename; $encoded = $this->encode_file($filename); } $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); $this->mimeOut = "--" . $mime_boundary . "\n"; $this->mimeOut .= "Content-Type: " . $mimetype . ";\n\tname=\"$szFilenameToDisplay\"\n"; $this->mimeOut .= "Content-Transfer-Encoding: quoted-printable\n"; $this->mimeOut .= "Content-Disposition: attachment;\n\tfilename=\"$szFilenameToDisplay\"\n\n"; if ( $mimetype == "message/rfc822" ) { $this->mimeOut .= "From: ".$szFromAddress."\n"; $this->mimeOut .= "To: ".$this->emailAddress."\n"; $this->mimeOut .= "Date: ".date("D, d M Y H:i:s") . " UT\n"; $this->mimeOut .= "Reply-To:".$szFromAddress."\n"; $this->mimeOut .= "Subject: ".$this->mailSubject."\n"; $this->mimeOut .= "X-Mailer: PHP/".phpversion()."\n"; $this->mimeOut .= "MIME-Version: 1.0\n"; } $this->mimeOut .= $contents."\n"; $this->mimeOut .= "--" . $mime_boundary . "--" . "\n"; return $out; // added -- to notify email client attachment is done } function getMimeHeaders($filename, $mime_filename="") { $mime_boundary = "--==================_846811060==_"; if ($mime_filename) { $filename = $mime_filename; } $out = "MIME-Version: 1.0\n"; $out .= "Content-Type: multipart/mixed;\n\tboundary=\"$mime_boundary\"\n\n"; $out .= "This message is in MIME format. Since your mail reader does not understand\n"; $out .= "this format, some or all of this message may not be legible."; return $out; } // // Split string by RFC 2045 semantics (76 chars per line, end with \r\n). // function myChunkSplit($str) { $stmp = $str; $len = strlen($stmp); $out = ""; while ($len > 0) { if ($len >= 76) { $out .= substr($stmp, 0, 76) . "\r\n"; $stmp = substr($stmp, 76); $len = $len - 76; } else { $out .= $stmp . "\r\n"; $stmp = ""; $len = 0; } } return $out; } // // Split the specified file up into a string and return it // function encode_file($sourcefile) { if (is_readable(phpbb_realpath($sourcefile))) { $fd = fopen($sourcefile, "r"); $contents = fread($fd, filesize($sourcefile)); $encoded = $this->myChunkSplit(base64_encode($contents)); fclose($fd); } return $encoded; } } // class emailer ?> |