class_mcMail.inc.php 1.45 KB
<?

class mcMail {

//	private static $tab = '	';

	private static $CollectionForMailToAdmin = array();

	public static function collectForMailToAdmin($param_to, $param_subject, $param_message, $param_logfile=null) {
		if(!array_key_exists($param_to, self::$CollectionForMailToAdmin)) {
			self::$CollectionForMailToAdmin[$param_to] = array();
		}
		self::$CollectionForMailToAdmin[$param_to][] = array(
			'subject' => $param_subject,
			'message' => $param_message
		);
//		mail($param_to, $param_subject, $param_message);
	}

	public static function mail($param_to, $param_subject, $param_message) {
		mail($param_to, $param_subject, $param_message);
	}

	public static function mailToAdmin() {
		foreach(self::$CollectionForMailToAdmin as $to => $array_message) {
			$subject = false;
			if(empty ($_GET)) {
				$message = false;
			} else {
				$message = mcCONST::LINEBREAK.'Url: '.urldecode(http_build_query($_GET)).mcCONST::LINEBREAK;
			}
			$message .= 'PHP: '. mcCONST::TAB.	PHP_VERSION . ' (' . PHP_OS . ')'.mcCONST::LINEBREAK.mcCONST::LINEBREAK;


			if(is_array($array_message)) {
				foreach($array_message as $var_message) {
					if($subject===false) {
						$subject = $var_message['subject'].'  ';
					} else {
						$subject .= '.';
					}
					$message .= mcCONST::LINEBREAK.mcCONST::LINEBREAK
									.$var_message['subject'].mcCONST::LINEBREAK
									. $var_message['message'].mcCONST::LINEBREAK;
				}
				self::mail($to, $subject, $message);
			}
		}
	}

}

?>