⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wp-mail.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
if (file_exists(dirname(__FILE__) .'/wp-mail-conf.php')) {
	@include_once(dirname(__FILE__) .'/wp-mail-conf.php');
	if ($exec_key) {
		if (!(isset($_GET['execkey'])) || $_GET['execkey']!=$exec_key) {
			return;
		}
	}
}
function wp_mail_quit() {
  global $wp_pop3;
  $wp_pop3->quit();
}
function wp_mail_receive() {
  global $xoopsDB, $wpdb, $siteurl, $blog_charset, $wp_pop3;

	require_once(ABSPATH . WPINC . '/class-pop3.php');
	timer_start();
	$use_cache = 1;
	$time_difference = get_settings('time_difference');

	// Get Server Time Zone
	// If Server Time Zone is not collect, Please comment out following line;
	$server_timezone = date("O");
	// echo "Server TimeZone is ".date('O')."<br />";

	// If Server Time Zone is not collect, Please uncomment following line and set collect timezone value;
	// $server_timezone = "+0900"; //This is a sample value for JST+0900

	$server_timezone = $server_timezone / 100;
	$weblog_timezone = $server_timezone + $time_difference;

	error_reporting(2037);

	$wp_pop3 = new POP3();

	if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
		echo "Ooops $wp_pop3->ERROR <br />\n";
		return;
	}

	$Count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
	if ($Count == false) {
		if (!$wp_pop3->FP) {
			echo "Oooops Login Failed: $wp_pop3->ERROR<br />\n";
		} else {
			echo "No Message<br />\n";
			$wp_pop3->quit();
		}
		return;
	}
	// ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
	register_shutdown_function('wp_mail_quit');

	for ($iCount = 1; $iCount <= $Count; $iCount++) {
		$MsgOne = $wp_pop3->get($iCount);
		if ((!$MsgOne) || (gettype($MsgOne) != 'array')) {
			echo "oops, $wp_pop3->ERROR<br />\n";
			$wp_pop3->quit();
			return;
		}

		$content = '';
		$content_type = '';
		$boundary = '';
		$att_boundary = '';
		$hatt_boundary = '';
		$bodysignal = 0;
		$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
			'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
		while (list ($lineNum, $line) = each ($MsgOne)) {
			if (strlen($line) < 3) {
				$bodysignal = 1;
			}
			if ($bodysignal) {
				$content .= $line;
			} else {
				if (preg_match('/^Content-Type:\s+(.*?)\;/i', $line,$match)) {
					$content_type = $match[1];
					$content_type = strtolower($match[1]);
				}
				if (($content_type == 'multipart/mixed') && (preg_match('/boundary=(?:")?([^;"\s\n]*?)(?:")?\s*(?:$|;)/',$line,$match)) && ($att_boundary == '')) {
					$att_boundary = trim($match[1]);
				}

				if (($content_type == 'multipart/alternative') && (preg_match('/boundary=(?:")?([^;"\s\n]*?)(?:")?\s*(?:$|;)/',$line,$match)) && ($boundary == '')) {
					$boundary = trim($match[1]);
				}

				if (($content_type == 'multipart/related') && (preg_match('/boundary=(?:")?([^;"\s\n]*?)(?:")?\s*(?:$|;)/',$line,$match)) && ($hatt_boundary == '')) {
					$hatt_boundary = trim($match[1]);
				}
				if (preg_match('/Subject: /', $line)) {
					$subject = trim($line);
					$subject = substr($subject, 9, strlen($subject)-9);
					if (function_exists('mb_decode_mimeheader')) {
						$subject1 = mb_decode_mimeheader($subject);
						if ($subject != $subject) {
							$sub_charset = mb_internal_encoding();
						} else {
							$sub_charset = "auto";
						}
						$subject = $subject1;
					}
					if (get_settings('use_phoneemail')) {
						$subject = explode(get_settings('phoneemail_separator'), $subject);
						$subject = trim($subject[0]);
					}
				}
				if (preg_match('/Date: /', $line)) { // of the form '20 Mar 2002 20:32:37'
					$ddate = trim($line);
					$ddate = str_replace('Date: ', '', $ddate);
					if (strpos($ddate, ',')) {
						$ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
					}
					$date_arr = explode(' ', $ddate);
					$date_time = explode(':', $date_arr[3]);

					$ddate_H = $date_time[0];
					$ddate_i = $date_time[1];
					$ddate_s = $date_time[2];

					$ddate_m = $date_arr[1];
					$ddate_d = $date_arr[0];
					$ddate_Y = $date_arr[2];

					$mail_timezone = trim(ereg_replace("\([^)]*\)", "", $date_arr[4])) / 100;
					// echo "Email TimeZone is {$date_arr[4]}<br />";
					$mail_time_difference = $weblog_timezone - $mail_timezone;
					for ($i = 0; $i < 12; $i++) {
						if ($ddate_m == $dmonths[$i]) {
							$ddate_m = $i + 1;
						}
					}
					$ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
					$ddate_U = $ddate_U + ($mai_time_difference * 3600);
					$post_date = date('Y-m-d H:i:s', $ddate_U);
				}
			}
		}
		if (!ereg(get_settings('subjectprefix'), $subject)) {
			continue;
		}

		$charset = "";
		$ncharset = preg_match("/\s?charset=\"?([A-Za-z0-9\-]*)\"?/i", $content, $matches);
		if ($ncharset) $charset = $matches[1];

		$ddate_today = time() + ($time_difference * 3600);
		$ddate_difference_days = ($ddate_today - $ddate_U) / 86400;

		if ($ddate_difference_days > 14) {
			echo "Too old<br />\n";
			continue;
		}
		if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) {
			$userpassstring = '';

			echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n";
			echo "<p><b>$iCount</b></p><p><b>Subject: </b>$subject</p>\n";

			$subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));

			$attachment = false;

			if ($att_boundary) {
				$contents = explode('--' . $att_boundary, $content);
				$content = $contents[1];
				$ncharset = preg_match("/\s?charset=\"?([A-Za-z0-9\-]*)\"?/i", $content, $matches);
				if ($ncharset) $charset = $matches[1];
				$content = explode("\r\n\r\n", $content, 2);
				$content = $content[1];
			}
			if ($hatt_boundary) {
				$contents = explode('--' . $hatt_boundary, $content);
				$content = $contents[1];
				if (preg_match('/Content-Type: multipart\/alternative\;\s*boundary\=(?:")?([^";\s\n]*?)(?:")?\s*(?:;|\n|$)"/i', $content, $matches)) {
					$boundary = trim($matches[1]);
					$content = explode('--' . $boundary, $content);
					$content = $content[2];
				}
				$ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
				if ($ncharset) $charset = $matches[1];
					$content = explode('Content-Transfer-Encoding: quoted-printable', $content);
				$content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
			} else if ($boundary) {
				$content = explode('--' . $boundary, $content);
				$content = $content[2];
				if (preg_match('/Content-Type: multipart\/related\;\s*boundary=(?:")?([^";\s\n]*?)(?:")?\s*(?:;|\n|$)/i', $content, $matches)) {
					$hatt_boundary = trim($matches[1]);
					$contents = explode('--' . $hatt_boundary, $content);
					$content = $contents[1];
				}
				$ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
				if ($ncharset) $charset = $matches[1];
				$content = explode('Content-Transfer-Encoding: quoted-printable', $content);
				$content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
			}
			$content = trim($content);
			echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
			echo "<p><b>att_boundary:</b> $att_boundary, <b>hatt_boundary:</b> $hatt_boundary</p>\n";
			echo "<p><b>charset:</b>$charset, <b>BLOG charset:</b>$blog_charset</p>\n";
			// echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';

			if (($charset == "") || (trim(strtoupper($charset)) == "ISO-2022-JP")) $charset = "JIS";
			if (trim(strtoupper($charset)) == "SHIFT_JIS") $charset = "SJIS";

			$btpos = strpos($content, get_settings('bodyterminator'));
			if ($btpos) {
				$content = substr($content, 0, $btpos);
			}
			$content = trim($content);

			$blah = explode("\n", preg_replace("/^[\n\r\s]*/", "", strip_tags($content)));
			$firstline = preg_replace("/[\n\r]/", "", $blah[0]);
			$secondline = $blah[1];

			if (get_settings('use_phoneemail')) {
				echo "<p><b>Use Phone Mail:</b> Yes</p>\n";
				$btpos = strpos($firstline, get_settings('phoneemail_separator'));
				if ($btpos) {
					$userpassstring = trim(substr($firstline, 0, $btpos));
					$content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
					$btpos = strpos($content, get_settings('phoneemail_separator'));
					if ($btpos) {
						$userpassstring = trim(substr($content, 0, $btpos));
						$content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
					}
				}
				$contentfirstline = $blah[1];
			} else {
				echo "<p><b>Use Phone Mail:</b> No</p>\n";
				$userpassstring = strip_tags($firstline);
				$contentfirstline = '';
			}

			$flat = 999.0;
			$flon = 999.0;
			$secondlineParts = explode(':', strip_tags($secondline));
			if (strncmp($secondlineParts[0], "POS", 3) == 0) {
				echo "Found POS:<br>\n";
				// echo "Second parts is:".$secondlineParts[1];
				// the second line is the postion listing line
				$secLineParts = explode(',', $secondlineParts[1]);
				$flatStr = $secLineParts[0];
				$flonStr = $secLineParts[1];
				// echo "String are ".$flatStr.$flonStr;
				$flat = floatval($secLineParts[0]);
				$flon = floatval($secLineParts[1]);
				// echo "values are ".$flat." and ".$flon;
				// ok remove that position... we should not have it in the final output
				$content = str_replace($secondline, '', $content);
			}

			$blah = explode(':', $userpassstring);
			$user_login = $blah[0];
			$user_pass = $blah[1];
			if (function_exists('xoopschina_mb_convert_encoding')) {
				$user_login = xoopschina_mb_convert_encoding(trim($user_login), $blog_charset, $charset);
			} else {
				$user_login = trim($user_login);
			}

			$content = $contentfirstline . str_replace($firstline, '', $content);
			$content = trim($content);
			// Please uncomment following line, only if you want to check user and password.
			// echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
			echo "<p><b>Login:</b> $user_login, <b>Pass:</b> *********</p>";
			if ($xoopsDB) {
				$sql = "SELECT ID, user_level FROM {$wpdb->users} WHERE user_login='$user_login' ORDER BY ID DESC LIMIT 1";
				$result = $wpdb->get_row($sql);
				if (!$result) {
					echo "<p><b>Wrong Login.</b></p></div>\n";
					continue;
				} else {
					$sql = "SELECT * FROM " . $xoopsDB->prefix('users') . " WHERE uname='$user_login' AND pass='" . md5(trim($user_pass)) . "' ORDER BY uid DESC LIMIT 1";
					$result1 = $wpdb->get_row($sql);

					if (!$result1) {
						echo "<p><b>Wrong login or password.</b></p></div>\n";
						continue;
					}
				}
			} else {
				$sql = "SELECT ID, user_level FROM {$wpdb->users} WHERE user_login='$user_login' AND user_pass='$user_pass' ORDER BY ID DESC LIMIT 1";
				$result = $wpdb->get_row($sql);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -