<?php
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ******************************************************************** >>
<< * ---------------------------------------------------------------- * >>
<< * Copyright ©2011-2012 Ozzy47                                      * >>
<< * All Rights Reserved. 											  * >>
<< * This file may not be redistributed in whole or significant part. * >>
<< * ---------------------------------------------------------------- * >>
<< * You are not allowed to use this on your server unless the files  * >>
<< * you downloaded were done so with permission.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

	// Do nothing during registration so we don't break the process & check if no links is active
	if (THIS_SCRIPT == 'private' AND $vbulletin->options['dbtech_vbsuper_pm_nolink_active'] AND $vbulletin->options['dbtech_vbsuper_pm_system_enabled'])
	{
// #################### DEFINE IMPORTANT CONSTANTS #######################	
		$user = $vbulletin->userinfo['musername'];

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################		
	//don't interfere with stock vBulletin errors		
	if (empty($pmdm->errors))
	{
			
			//No email's in PM title
			if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['dbtech_vbsuper_pm_no_email_title']))) 
			{
			if (
					preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]+\.+[a-z]{2,6}))#si', $pm['title']) 
					OR 
					preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]))#si', $pm['title'])
				)
				{
					if ($vbulletin->options['dbtech_vbsuper_pm_nolink_error_type'] == 1) //Popup Message
					{
						//Switch vBulletin Message header
						$vbulletin->templatecache['STANDARD_ERROR'] = str_replace(
							'\' . vB_Template_Runtime::parsePhrase("vbulletin_message") . \'',
							'\' . vB_Template_Runtime::parsePhrase("dbtech_vbsuper_pm_blocked_error_occured") . \'',
							$vbulletin->templatecache['STANDARD_ERROR']
						);
						//Error message block
						eval(standard_error(fetch_error('dbtech_vbsuper_pm_no_email_title', $user)));
					}
					else
					{
						//Switch error message
						$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_no_email_error_title'];
	 					//Switch subheader message
	  					$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
	   					//Show error
	    				$pmdm->error('dbtech_vbsuper_pm_no_email_error_title',$user);	           			
					}
				}
			}
		
			//No email's in PM message	
			if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['dbtech_vbsuper_pm_no_email_message']))) 
			{
			if (
					preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]+\.+[a-z]{2,6}))#si', $pm['message']) 
					OR 
					preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]))#si', $pm['message'])
				)
				{
					if ($vbulletin->options['dbtech_vbsuper_pm_nolink_error_type'] == 1) //Popup Message
					{
						//Switch vBulletin Message header
						$vbulletin->templatecache['STANDARD_ERROR'] = str_replace(
							'\' . vB_Template_Runtime::parsePhrase("vbulletin_message") . \'',
							'\' . vB_Template_Runtime::parsePhrase("dbtech_vbsuper_pm_blocked_error_occured") . \'',
							$vbulletin->templatecache['STANDARD_ERROR']
						);
						//Error message block
						eval(standard_error(fetch_error('dbtech_vbsuper_pm_no_email_message', $user)));
					}
					else
					{
						//Switch error message
						$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_no_email_error_title'];
	 					//Switch subheader message
	 					$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
	 					$pmdm->error('dbtech_vbsuper_pm_no_email_error_message',$user);
					}
				}
			}	
			
			//No links in PM title
			if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['dbtech_vbsuper_pm_nolink_cant_send']))) 
			{
			if (
					preg_match('/((?:[-a-z0-9]\:\/\/|[-a-z0-9]\.)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/i', $pm['title'])
					AND 
					!preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]+\.+[a-z]{2,6}))#si', $pm['title']) 
					AND 
					!preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]))#si', $pm['title'])		
				)
				{
					if ($vbulletin->options['dbtech_vbsuper_pm_nolink_error_type'] == 1) //Popup Message
					{
						//Switch vBulletin Message header
						$vbulletin->templatecache['STANDARD_ERROR'] = str_replace(
							'\' . vB_Template_Runtime::parsePhrase("vbulletin_message") . \'',
							'\' . vB_Template_Runtime::parsePhrase("dbtech_vbsuper_pm_blocked_error_occured") . \'',
							$vbulletin->templatecache['STANDARD_ERROR']
						);
						//Error message block
						eval(standard_error(fetch_error('dbtech_vbsuper_pm_nolink_title', $user)));
					}
					else
					{
						//Switch error message
						$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_nolink_error_title'];
	 					//Switch subheader message
	  					$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
	   					$pmdm->error('dbtech_vbsuper_pm_nolink_error_title',$user);
	     			}
				}
			}
		
			//No links in PM message	
			if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['dbtech_vbsuper_pm_nolink_message']))) 
			{
			if (	
					preg_match('/((?:[-a-z0-9]\:\/\/|[-a-z0-9]\.)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/i', $pm['message'])
					AND 
					!preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]+\.+[a-z]{2,6}))#si', $pm['messager']) 
					AND 
					!preg_match('#[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]))#si', $pm['message']) 			
	    		) 
				{
					if ($vbulletin->options['dbtech_vbsuper_pm_nolink_error_type'] == 1) //Popup Message
					{
						//Switch vBulletin Message header
						$vbulletin->templatecache['STANDARD_ERROR'] = str_replace(
							'\' . vB_Template_Runtime::parsePhrase("vbulletin_message") . \'',
							'\' . vB_Template_Runtime::parsePhrase("dbtech_vbsuper_pm_blocked_error_occured") . \'',
							$vbulletin->templatecache['STANDARD_ERROR']
						);
						//Error message block
						eval(standard_error(fetch_error('dbtech_vbsuper_pm_nolink_message', $user)));
					}
					else
					{
						//Switch error message
						$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_nolink_error_title'];
	  					//Switch subheader message
	    				$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
	     				$pmdm->error('dbtech_vbsuper_pm_nolink_error_message',$user);
	       			}
				}
			}			
		}
	}
//}

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ********************************************************************* >>
<< * Created: 09:30, Fri June 8th 2012                                 * >>
<< * VER: 1.0.0                                                        * >>
<< ********************************************************************* >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
?>