File: /home/bt667/public_html/wp-content/plugins/wp_mvplayer/includes/web-optin.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $wpdb;
$video_table = $wpdb->prefix . "mvplayer_video";
$video_detail = $wpdb->get_row("SELECT * FROM $table_name where id= $vid");
if($video_detail == ""){
$video_detail = $wpdb->get_row("SELECT * FROM wp_playlist_video where id= $vid");
}
$webform_code = stripslashes($data->custom_formcode);
$webform_submit_text = $data->optin_webform_submit_text;
$pattern ='((<(\s*)(input)[^<>]+(hidden|text|email)[^<>]+>)|(<(\s*)(form)[^<>]+(action)[^<>]+>)|(<script[^>]*>[\s\S]*?</script>))';
preg_match_all($pattern,$webform_code,$strings);
$name_string='';
$email_string='';
$form_string = '';
$form_string_end = '';
$hidden_string = '';
foreach($strings[0] as $string){
if(preg_match('(type="hidden")i',$string)){
$hidden_string.=$string;
}else if(preg_match('(type="text|email")i',$string)){
$string = preg_replace('/[\s]+(value)=[\s]*("[^"]*"|\'[^\']*\')/i',"",$string);
$string = preg_replace('/[\s]+(value)=[\s]*[^ |^>]*/i',"",$string);
$pattern = '(name="[\w]*name")i';
preg_match($pattern,$string,$name);
if(count($name)){
$replacer = $name[0].' value="" onfocus="" onblur="" class="Name" id="username_'.$player_id.'"';
$name_string = '<input '.$name[0].' value="" placeholder="Name" onfocus="" onblur="" class="Name" id="username_'.$player_id.'" type="text">';
}
$pattern = '(name="[\w]*email")i';
preg_match($pattern,$string,$email);
if(count($email)){
$replacer = $email[0].' value="" onfocus="" onblur="" class="Email" id="useremail_'.$player_id.'"';
$email_string = '<input '.$email[0].' value="" placeholder="Email" onfocus="" onblur="" class="Email" id="useremail_'.$player_id.'" type="text">';
}
}else if(preg_match('(form)i',$string)){
$form_string = $string;
if(!preg_match('/<form.*?target=[^>]*?>/', $form_string)){
$form_string = str_replace('<form', '<form target="_blank" ', $form_string);
}
$form_string_end = $string;
}
}
?>
<div class="optinbox" id="show_optinbox_<?php echo $player_id; ?>" style="display:none;">
<div class="optinmain">
<div id="optin_head"><center><?php echo $OptinHeadline;?></center></div>
<div id="optin_text"><center><?php echo $OptinText;?></center></div>
<center>
<?php echo $form_string; ?>
<div class="textfield">
<div class="inputfield"><?php echo $name_string; ?></div>
<div class="inputfield"><?php echo $email_string; ?></div>
<div>
<?php echo $hidden_string; ?>
<input type="submit" id="optinsubmit" onClick="return optin_submit_<?php echo $player_id; ?>()" class="optin_submit_<?php echo $player_id; ?>" value="<?php echo $OptinSubmitText;?>" />
<?php if($OptinAllowSkip=='yes'){ ?>
<a id="optinskip" href="javascript:optinHideIt_<?php echo $player_id;?>()"><?php __('Skip','mvp'); ?></a>
<?php } ?>
</div>
</div>
</center>
</div>
</div>
<script language="javascript">
function testAttribute(element, attribute){
var test = document.createElement(element);
if(attribute in test)
return true;
else
return false;
}
if(!testAttribute("input", "placeholder")){
window.onload = function(){
var demo1 = document.getElementById('username_<?php echo $player_id; ?>');
var text_content = '<?php echo __("Name","mvp"); ?>';
demo1.style.color = "gray";
demo1.value = text_content;
demo1.onfocus = function() {
if (this.style.color == "gray")
{ this.value = ""; this.style.color = "black"; }
}
demo1.onblur = function() {
if (this.value == ""){ this.style.color = "gray"; this.value = text_content; }
}
var demo2 = document.getElementById('useremail_<?php echo $player_id; ?>');
var text_content2 = '<?php echo __("Email","mvp"); ?>';
demo2.style.color = "gray";
demo2.value = text_content2;
demo2.onfocus = function() {
if (this.style.color == "gray"){ this.value = ""; this.style.color = "black"; }
}
demo2.onblur = function() {
if (this.value == ""){ this.style.color = "gray"; this.value = text_content2; }
}
}
}
function validation(){
var mailformat = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var username = jQuery("#username_<?php echo $player_id; ?>").val();
var useremail = jQuery("#useremail_<?php echo $player_id; ?>").val();
var username_validation = '<?php echo __('Name and Email are Required.','mvp') ?>';
var name_validation = '<?php echo __('Name is Required.','mvp') ?>';
var email_validation = '<?php echo __('Email is Required.','mvp') ?>';
var email_format_validation = '<?php echo __('Email is Invalid.','mvp') ?>';
if(!username && !useremail){alert(username_validation);
return false;
}else if(!username){alert(name_validation);
return false;
}else if(!useremail){alert(email_validation);
return false;
}else if(useremail){
if(!useremail.match(mailformat)){
alert(email_format_validation);
return false;
}else if(useremail.match(mailformat) && username){
return true;
}
}
}
function optin_submit_<?php echo $player_id; ?>(){
if(validation()){
<?php echo 'optinHideIt_'.$player_id.'();';?>
return true;
}
return false;
}
</script>