mirror of
https://gitlab.com/openlp/website.git
synced 2024-12-22 13:02:50 +00:00
Add a contact us script to handle posting the contact form
This commit is contained in:
parent
bbc0f175bf
commit
4084a8d0b1
4
conf.py
4
conf.py
@ -676,6 +676,10 @@ COPY_SOURCES = False
|
|||||||
#<link href="css/style.css" rel="stylesheet">
|
#<link href="css/style.css" rel="stylesheet">
|
||||||
#<link href="css/custom.css" rel="stylesheet">
|
#<link href="css/custom.css" rel="stylesheet">
|
||||||
#"""
|
#"""
|
||||||
|
EXTRA_HEAD_DATA = """
|
||||||
|
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||||
|
"""
|
||||||
|
|
||||||
# Google Analytics or whatever else you use. Added to the bottom of <body>
|
# Google Analytics or whatever else you use. Added to the bottom of <body>
|
||||||
# in the default template (base.tmpl).
|
# in the default template (base.tmpl).
|
||||||
# (translatable)
|
# (translatable)
|
||||||
|
78
files/contact-us.php
Normal file
78
files/contact-us.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
ini_set("include_path", '/home/openlp/php:' . ini_get("include_path") );
|
||||||
|
|
||||||
|
require_once('Services/JSON.php');
|
||||||
|
require_once('Mail.php');
|
||||||
|
|
||||||
|
function redirect($url, $status_code = 303)
|
||||||
|
{
|
||||||
|
header('Location: ' . $url, true, $status_code);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that this isn't spam
|
||||||
|
$remote_ip = '';
|
||||||
|
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||||
|
$remote_ip = end(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$remote_ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up parameters
|
||||||
|
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||||
|
$fields = array(
|
||||||
|
'secret' => '6Lc7Hg4TAAAAAP7o80vkVc9rwBXAeo9PlN3Q7khh',
|
||||||
|
'response' => $_POST['g-recaptcha-response'],
|
||||||
|
'remoteip', $remote_ip
|
||||||
|
);
|
||||||
|
$fields_string = http_build_query($fields);
|
||||||
|
|
||||||
|
// Open connection
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
// Set the url, number of POST vars, POST data
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, count($fields));
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
// Execute post
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
|
||||||
|
// Close connection
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
// Parse response
|
||||||
|
if ($result !== false && $result !== true) {
|
||||||
|
$json = new Services_JSON();
|
||||||
|
$api_response = $json->decode($result);
|
||||||
|
if ($api_response->success !== true) {
|
||||||
|
error_log('Error from verification: ' . print_r($api_response, true));
|
||||||
|
redirect('https://openlp.org/?m=0#support');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error_log('Got an error code: ' . $response_status);
|
||||||
|
redirect('https://openlp.org/?m=0#support');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get everything together
|
||||||
|
$headers['From'] = $_POST['name'] . ' <' . $_POST['email'] . '>';
|
||||||
|
$headers['To'] = 'support@openlp.org';
|
||||||
|
$headers['Subject'] = $_POST['subject'];
|
||||||
|
$body = $_POST['message'];
|
||||||
|
$recipients = 'support@openlp.org';
|
||||||
|
if ($_POST['me-too']) {
|
||||||
|
$recipients .= ',' . $_POST['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the mail object using the Mail::factory method
|
||||||
|
$mail_object =& Mail::factory('mail');
|
||||||
|
$result = $mail_object->send($recipients, $headers, $body);
|
||||||
|
if ($result !== true) {
|
||||||
|
error_log(print_r($result, true));
|
||||||
|
redirect('https://openlp.org/?m=0#support');
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect('https://openlp.org/?m=1#support');
|
@ -304,3 +304,13 @@ article blockquote p:first-child {
|
|||||||
.scrollToTop a {
|
.scrollToTop a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkbox input[type="checkbox"] {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox > label {
|
||||||
|
color: #888;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.42857;
|
||||||
|
}
|
@ -19,4 +19,18 @@ $(function(){
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('html, body').animate({scrollTop: 0}, 300);
|
$('html, body').animate({scrollTop: 0}, 300);
|
||||||
});
|
});
|
||||||
|
var queryParams = location.search.slice(1).split("&");
|
||||||
|
var params = {};
|
||||||
|
queryParams.forEach(function (value) {
|
||||||
|
var parts = value.split("=");
|
||||||
|
params[parts[0]] = parts[1];
|
||||||
|
});
|
||||||
|
if (params.hasOwnProperty("m")) {
|
||||||
|
if (params.m == 1) {
|
||||||
|
$("#success-alert").removeClass("hidden");
|
||||||
|
}
|
||||||
|
else if (params.m == 0) {
|
||||||
|
$("#error-alert").removeClass("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -405,22 +405,41 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
<form role="form" id="footer-form">
|
<div id="success-alert" class="hidden alert alert-success" role="alert">
|
||||||
|
<i class="fa fa-fw fa-check"></i> Your message has been sent! We'll get back to you as soon as we can.
|
||||||
|
</div>
|
||||||
|
<div id="error-alert" class="hidden alert alert-danger" role="alert">
|
||||||
|
<i class="fa fa-fw fa-exclamation-triangle"></i> Oh dear! Something went wrong while sending your message.
|
||||||
|
</div>
|
||||||
|
<form role="form" id="footer-form" method="post" action="/contact-us.php">
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<label class="sr-only" for="name2">Name</label>
|
<label class="sr-only" for="name">Name</label>
|
||||||
<input type="text" class="form-control" id="name2" placeholder="Name" name="name2" required>
|
<input type="text" class="form-control" id="name" placeholder="Name" name="name" required>
|
||||||
<i class="fa fa-user form-control-feedback"></i>
|
<i class="fa fa-user form-control-feedback"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<label class="sr-only" for="email2">Email address</label>
|
<label class="sr-only" for="email">Email address</label>
|
||||||
<input type="email" class="form-control" id="email2" placeholder="Enter email" name="email2" required>
|
<input type="email" class="form-control" id="email" placeholder="E-mail address" name="email" required>
|
||||||
<i class="fa fa-envelope form-control-feedback"></i>
|
<i class="fa fa-envelope form-control-feedback"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<label class="sr-only" for="message2">Message</label>
|
<label class="sr-only" for="subject">Subject</label>
|
||||||
<textarea class="form-control" rows="8" id="message2" placeholder="Message" name="message2" required></textarea>
|
<input type="text" class="form-control" id="subject" placeholder="Subject" name="subject" required>
|
||||||
|
<i class="fa fa-comment form-control-feedback"></i>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<label class="sr-only" for="message">Message</label>
|
||||||
|
<textarea class="form-control" rows="8" id="message" placeholder="Message" name="message" required></textarea>
|
||||||
<i class="fa fa-pencil form-control-feedback"></i>
|
<i class="fa fa-pencil form-control-feedback"></i>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkbox has-feedback">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="me-too" value="1"> Send me a copy
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<div class="g-recaptcha" data-sitekey="6Lc7Hg4TAAAAALVlRY_kP29PpAFkF90UW1dVDgJR"></div>
|
||||||
|
</div>
|
||||||
<input type="submit" value="Send" class="btn btn-default">
|
<input type="submit" value="Send" class="btn btn-default">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user