Skip to content

Instantly share code, notes, and snippets.

@nacimux
Created November 24, 2016 13:58
Show Gist options
  • Select an option

  • Save nacimux/dff643fe579d4f8a836de31a1ace8199 to your computer and use it in GitHub Desktop.

Select an option

Save nacimux/dff643fe579d4f8a836de31a1ace8199 to your computer and use it in GitHub Desktop.
<?php global $smof_data; ?>
<?php
define('AUTOCHECKER_ACCESS_KEY', '897az87451785gfsoiuy878');
if(isset($_POST['submitted'])) {
if(trim($_POST['contactName']) == '') {
$nameError = __('Please enter your name.', 'rocknrolla');
$hasError = true;
} else {
$contactName = trim($_POST['contactName']);
}
if(trim($_POST['contactEmail']) == '') {
$emailError = __('Please enter your email address.', 'rocknrolla');
$hasError = true;
} else if (!preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/", trim($_POST['contactEmail']))) {
$emailError = __('You entered an invalid email address.', 'rocknrolla');
$hasError = true;
} else {
$contactEmail = trim($_POST['contactEmail']);
}
if(isset($_POST['autocheckerAccessKey']) && $_POST['autocheckerAccessKey'] == AUTOCHECKER_ACCESS_KEY){
$autochecker = true;
}
if (! MyCaptcha::verify() &&
// Give access to the auto contact email checker.
! isset($autochecker)) {
$messageError = 'Les caractères du captcha ne sont pas valides';
$hasError = true;
}
$contactSubject = trim($_POST['contactSubject']);
if(trim($_POST['contactMessage']) == '') {
$messageError = __('Please enter a message.', 'rocknrolla');
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$contactMessage = stripslashes(trim($_POST['contactMessage']));
} else {
$contactMessage = trim($_POST['contactMessage']);
}
}
if(!isset($hasError)) {
$emailTo = get_option('admin_email');
$subject = $contactSubject;
$body = 'Nom: '.$contactName.' Email: '.$contactEmail."\n\n".$contactMessage;
$headers = 'From: [email protected] <[email protected]>' . "\r\n" . 'Reply-To: ' . $contactEmail;
if( wp_mail($emailTo, $subject, $body, $headers) ) {
$emailSent = true;
}
}
if(isset($_GET['ajax'])) {
if(isset($emailSent) && $emailSent == true) {
echo '<span id="msg-fm-contact">Votre message à bien été envoyé. Merci. </span>';
} else if(isset($hasError) && $hasError == true) {
echo '<span id="msg-fm-contact">'.$messageError.'</span>';
}
}
} ?>
<?php if( $smof_data['rnr_enable_googlemap']) { ?>
<div class="row contact-map">
<script type="text/javascript">
jQuery(document).ready(function() {
function initialize() {
var secheltLoc = new google.maps.LatLng(<?php echo $smof_data['rnr_map_lat']; ?>,<?php echo $smof_data['rnr_map_lon']; ?>);
var myMapOptions = {
center: secheltLoc
,mapTypeId: google.maps.MapTypeId.ROADMAP
,zoom: <?php echo $smof_data['rnr_map_zoom']; ?> , scrollwheel: false,mapTypeControl: false, zoomControl: false, draggable: false
};
var theMap = new google.maps.Map(document.getElementById("google-map"), myMapOptions);
var image = new google.maps.MarkerImage(
'<?php echo get_template_directory_uri().'/images/pinMap.png'; ?>',
new google.maps.Size(17,26),
new google.maps.Point(0,0),
new google.maps.Point(8,26)
);
var shadow = new google.maps.MarkerImage(
'<?php echo get_template_directory_uri().'/images/pinMap-shadow.png'; ?>',
new google.maps.Size(33,26),
new google.maps.Point(0,0),
new google.maps.Point(9,26)
);
var marker = new google.maps.Marker({
map: theMap,
icon: image,
shadow: shadow,
draggable: false,
animation: google.maps.Animation.DROP,
position: secheltLoc,
visible: true
});
var boxText = document.createElement("div");
boxText.innerHTML = '<div class="captionMap animated bounceInDown"><img src="<?php echo $smof_data['rnr_map_logo']; ?>" class="alignleft" alt="Contact Address"> <span><?php echo $smof_data['rnr_contact_address']; ?></span></div>';
var myOptions = {
content: boxText
,disableAutoPan: false,maxWidth: 0
,pixelOffset: new google.maps.Size(-140, 0)
,zIndex: null
,boxStyle: {
width: "280px"
}
,closeBoxURL: ""
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
google.maps.event.addListener(theMap, "click", function (e) {
ib.open(theMap, this);
});
var ib = new InfoBox(myOptions);
ib.open(theMap, marker);
}
google.maps.event.addDomListener(window, 'load', initialize);
});
</script>
<div id="google-map" class="embed clearfix">
<div class="mapPreLoading">
<span><h4>Loading</h4></span>
<span class="l-1"></span>
<span class="l-2"></span>
<span class="l-3"></span>
<span class="l-4"></span>
<span class="l-5"></span>
<span class="l-6"></span>
</div>
</div>
</div>
<?php } ?>
<div class="container">
<div class="row">
<div class="sixteen columns">
<!-- START CONTACT FORM -->
<div>
<!-- <form action="<?php the_permalink(); ?>" method="post" class="contactForm form" id="contact-form"> -->
<form action="<?php get_home_url(); ?>?ajax=true" method="post" class="contactForm form" id="contact-form">
<div id="contact-input">
<input type="text" name="contactName" class="required" id="contactName" value="<?php if($_GET['lang'] == 'en') { echo "Name"; } else if($_GET['lang'] == 'fr' OR !isset($_GET['lang'])) { echo "Nom";} else{ echo "Nombre"; } ?>" />
<input type="text" name="contactEmail" class="required" id="contactEmail" value="<?php _e('E-mail', 'rocknrolla'); ?>" />
<input type="text" name="contactSubject" class="required" id="contactSubject" value="<?php if($_GET['lang'] == 'en') { echo "Subject"; } else if($_GET['lang'] == 'fr' OR !isset($_GET['lang']) ) { echo "Sujet";} else{ echo "Sujeto"; } ?>" />
</div>
<div id="contact-textarea">
<textarea class="required" name="contactMessage" id="contactMessage" rows="" cols=""><?php if($_GET['lang'] == 'en') { echo "Message"; } else if($_GET['lang'] == 'fr' OR !isset($_GET['lang'])) { echo "Message";} else{ echo "Mensaje"; } ?></textarea>
</div>
<div id="captcha-block">
<?php
new MyCaptcha( array(
'chars_num'=> '5', // number of characters
'tcolor' => 'FF0000', // text color
'ncolor' => '999999', // noise color
) );
?>
</div>
<div id="contact-submit">
<input type="hidden" name="submitted" id="submitted" value="true" />
<input type="submit" value="<?php _e('Send', 'rocknrolla'); ?>" class="comment-submit button submit" id="submitform" />
<span id="msg"></span>
</div>
</form>
<div class="clear"></div>
</div>
<!-- END CONTACT FORM -->
</div><!-- END OF SPAN5 -->
</div>
</div><!-- END OF CONTAINER -->
@saxbophone
Copy link

I'm not sure if I should be able to see this...

If this is sensitive, you can make it into a secret gist.

If it is not sensitive, then please disregard my comments, happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment