<?
/*
Plugin Name:WPmail-override
Plugin URI: http://my.gold-ticket.com
Description:Stops emails and sends messages thru GT
Version:1.0
*/

if(!function_exists( 'wp_mail')){
	function wp_mail($to,$subject,$message,$headers=''){
		/*if it is a gt member send thru gt*/
									$t=$_POST['user_login'];
									$t=strtoupper($t);
					if(($to=='')||(strpos($to,'@')>0)){
						$user_l = get_user_by( 'login', $t );
						$user = new WP_User( $user_l->ID );
						$user_obj = get_userdata( $user_l->ID );
						$mr=$user_obj->roles[0];
						

						if($mr=='members'){
									$my_post = array(
												  'post_title'    => 'to '.$to,
												  'content'.$to."ID=".$user_obj->roles[0].' '.$message,
												  'post_status'   => 'publish',
												  'post_author'   => 1,
												  'post_category' => array(8,39)
												);
									/*$t=$_POST['user_login'];
									$t=strtoupper($t);*/
									preg_match('/\[ ?([a-z]+) ?: ?([a-z]+) ?\]/i', $message, $out);
				       
									$code="WEB";
									$to="NET ";//.$t;
									$authkey="21513969";
									$msg="message: ".$message."to: ".$_POST['user_login'];
							//wp_remote_request('http://gold-ticket.net/dev/webservices/GTold1.php?a=WEBMhdKxVHh__iLhSfgaCbEf21513969MhdKxVHh__iLhSfgaCbEfSTOREMhdKxVHh__iLhSfgaCbEf0MhdKxVHh__iLhSfgaCbEf'.$msg.'MhdKxVHh__iLhSfgaCbEfNETMhdKxVHh__iLhSfgaCbEfMhdKxVHh__iLhSfgaCbEf' );
									$body = array(
									    'a' => $code.'MhdKxVHh__iLhSfgaCbEf'.$authkey.'MhdKxVHh__iLhSfgaCbEfSTOREMhdKxVHh__iLhSfgaCbEf0MhdKxVHh__iLhSfgaCbEf'.$msg.'MhdKxVHh__iLhSfgaCbEf'.$to.'MhdKxVHh__iLhSfgaCbEfMhdKxVHh__iLhSfgaCbEf'
									    );
				 
									$args = array(
									    'body' => $body,
									    'timeout' => '5',
									    'redirection' => '5',
									    'httpversion' => '1.0',
									    'blocking' => true,
									    'headers' => array(),
									    'cookies' => array()
									);
				 
							$response = wp_remote_post( 'http://gold-ticket.net/dev/webservices/GTold1.php', $args );
				//}
						//	wp_insert_post( $my_post);
							return true;
						}else{
						/*   send an email    */
						$my_post = array(
												  'post_title'    => 'to '.$to,
												  'post_content'  => 'content'.$to."ID=".$user_obj->roles[0].' '.$message,
												  'post_status'   => 'publish',
												  'post_author'   => 1,
												  'post_category' => array(8,39)
												);
					//	wp_insert_post( $my_post);
							mail($to, $subject, $message, "From:lucas@gold-ticket.com");
							return true;
					}
				}
				
	}
}



?>
{"version":"1.0","provider_name":"New Gold-ticket","provider_url":"https:\/\/gold-ticket.com\/new","author_name":"lucas","author_url":"https:\/\/gold-ticket.com\/new\/author\/lucas\/","title":"About Us","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\"><a href=\"https:\/\/gold-ticket.com\/new\/about-us\/\">About Us<\/a><\/blockquote>\n<script type='text\/javascript'>\n<!--\/\/--><![CDATA[\/\/><!--\n\t\t!function(d,l){\"use strict\";var e=!1,n=!1;if(l.querySelector)if(d.addEventListener)e=!0;if(d.wp=d.wp||{},!d.wp.receiveEmbedMessage)if(d.wp.receiveEmbedMessage=function(e){var t=e.data;if(t)if(t.secret||t.message||t.value)if(!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var r,i,a,s=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),n=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),o=new RegExp(\"^https?:$\",\"i\"),c=0;c<n.length;c++)n[c].style.display=\"none\";for(c=0;c<s.length;c++)if(r=s[c],e.source===r.contentWindow){if(r.removeAttribute(\"style\"),\"height\"===t.message){if(1e3<(a=parseInt(t.value,10)))a=1e3;else if(~~a<200)a=200;r.height=a}if(\"link\"===t.message)if(i=l.createElement(\"a\"),a=l.createElement(\"a\"),i.href=r.getAttribute(\"src\"),a.href=t.value,o.test(a.protocol))if(a.host===i.host)if(l.activeElement===r)d.top.location.href=t.value}}},e)d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",t,!1),d.addEventListener(\"load\",t,!1);function t(){if(!n){n=!0;for(var e,t,r=-1!==navigator.appVersion.indexOf(\"MSIE 10\"),i=!!navigator.userAgent.match(\/Trident.*rv:11\\.\/),a=l.querySelectorAll(\"iframe.wp-embedded-content\"),s=0;s<a.length;s++){if(!(e=a[s]).getAttribute(\"data-secret\"))t=Math.random().toString(36).substr(2,10),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t);if(r||i)(t=e.cloneNode(!0)).removeAttribute(\"security\"),e.parentNode.replaceChild(t,e)}}}}(window,document);\n\/\/--><!]]>\n<\/script><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/gold-ticket.com\/new\/about-us\/embed\/\" width=\"600\" height=\"338\" title=\"&#8220;About Us&#8221; &#8212; New Gold-ticket\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe>"}