Compare commits
No commits in common. "f4380879cde6de625527418819a5a0675d92d821" and "09d6e22f670d136263928225d4332b12215a40b7" have entirely different histories.
f4380879cd
...
09d6e22f67
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016 eekdood
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
<?PHP
|
|
||||||
$conf = array(
|
|
||||||
|
|
||||||
// 'referrals' is a list of web site domains separated by commas. Only requests originating from
|
|
||||||
// these domains will be processed.
|
|
||||||
'referrals' => "domain.com",
|
|
||||||
|
|
||||||
// Google reCaptcha v2 secret. Obtain your key from https://www.google.com/recaptcha/admin/create
|
|
||||||
// Enter your secret key below and be sure to integrate reCaptcha into your site with your site key.
|
|
||||||
//
|
|
||||||
// <script src="https://www.google.com/recaptcha/api.js"></script>
|
|
||||||
// <div class="g-recaptcha" data-sitekey="your_site_key"></div>
|
|
||||||
//
|
|
||||||
// Leave blank to disable (Not a good idea).
|
|
||||||
'reCaptchaSecret' => "",
|
|
||||||
|
|
||||||
// 'excludeFields' is a list of field names separated by commas. Field names listed here will not
|
|
||||||
// be included in the resulting email of this script.
|
|
||||||
// NOTE: The fields "recipient, subject, required, redirect, mailtemplate, mailtemplatehtml" are
|
|
||||||
// used by this script and are automagically added later in the script.
|
|
||||||
'excludeFields' => "",
|
|
||||||
|
|
||||||
// 'defaultFrom' is an email address in proper form. This is the default from address used to send
|
|
||||||
// mail if there is no field "email" sent to this script.
|
|
||||||
'defaultFrom' => 'sendform@domain.com',
|
|
||||||
|
|
||||||
// 'defaultSubject' is a String. This is the default subject used if there is no field "subject"
|
|
||||||
// sent to this script.
|
|
||||||
'defaultSubject' => "SendForm Results",
|
|
||||||
|
|
||||||
// 'defaultReq' is a list of field names separated by commas. Field names listed here are assumed
|
|
||||||
// required for the script to run.
|
|
||||||
// NOTE: The field "recipient" is required by this script and will always be checked.
|
|
||||||
'defaultReq' => "",
|
|
||||||
|
|
||||||
// 'defaultIgnoreEmpty' is either true or false. If true, the script will ignore all empty fields
|
|
||||||
// and return only fields that contain data. Useful if you have optional fields and do not
|
|
||||||
// want to output them to the resulting email.
|
|
||||||
'defaultIgnoreEmpty' => false,
|
|
||||||
|
|
||||||
// 'smtpEnable' enables or disables the SMTP sending method. Enter 1 to turn it on or 0 to turn it off
|
|
||||||
// 'smtpHost', 'smtpUser', 'smtpPass' only need to be filled if 'smtpEnable' is set to 1
|
|
||||||
'smtpEnable' => 0,
|
|
||||||
'smtpHost' => "mail.server.com",
|
|
||||||
'smtpUser' => "johndoe@domain.com",
|
|
||||||
'smtpPass' => "passwerd",
|
|
||||||
|
|
||||||
// 'errorTo' is a valid email address that will receive a simple notification for each error that occurs.
|
|
||||||
// Leave blank to turn off. NOTE: this function does not support the SMTP sending method.
|
|
||||||
'errorTo' => "";
|
|
||||||
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
94
sendform.php
94
sendform.php
|
|
@ -1,13 +1,63 @@
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
require_once("sendform.conf");
|
// $referals is a list of web site domains seperated by commas. Only requests originating from
|
||||||
|
// these domains will be processed.
|
||||||
if ($conf['defaultReq'] != "") $conf['defaultReq'] .= ", recipient";
|
$referals = "domain.com";
|
||||||
else $conf['defaultReq'] = "recipient";
|
|
||||||
|
|
||||||
$conf['referrals'] = explode(",", $conf['referrals']);
|
// Google reCaptcha v2 secret. Obtain your key from https://www.google.com/recaptcha/admin/create
|
||||||
$conf['excludeFields'] = explode(",", "recipient, ccrecipient, bccrecipient, subject, required, redirect, mailtemplate, mailtemplatehtml, submit, submit_x, submit_y, verification, ignoreempty, g-recaptcha-response, " . $conf['excludeFields']);
|
// Enter your secret key below and be sure to integrate reCaptcha into your site with your site key.
|
||||||
$srequired = explode(",", $conf['defaultReq']);
|
//
|
||||||
|
// <script src="https://www.google.com/recaptcha/api.js"></script>
|
||||||
|
// <div class="g-recaptcha" data-sitekey="your_site_key"></div>
|
||||||
|
//
|
||||||
|
// Leave blank to disable (Not a good idea).
|
||||||
|
$reCaptchaSecret = "";
|
||||||
|
|
||||||
|
// $excludeFields is a list of field names seperated by commas. Field names listed here will not
|
||||||
|
// be included in the resulting email of this script.
|
||||||
|
// NOTE: The fields "recipient, subject, required, redirect, mailtemplate, mailtemplatehtml" are
|
||||||
|
// used by this script and are automagically added later in the script.
|
||||||
|
$excludeFields = "";
|
||||||
|
|
||||||
|
// $defaultFrom is an email address in proper form. This is the default from address used to send
|
||||||
|
// mail if there is no field "email" sent to this script.
|
||||||
|
$defaultFrom = 'sendform@domain.com';
|
||||||
|
|
||||||
|
// $defaultSubject is a String. This is the default subject used if there is no field "subject"
|
||||||
|
// sent to this script.
|
||||||
|
$defaultSubject = "SendForm Results";
|
||||||
|
|
||||||
|
// $defaultReq is a list of field names seperated by commas. Field names listed here are assumed
|
||||||
|
// required for the script to run.
|
||||||
|
// NOTE: The field "recipient" is required by this script and will always be checked.
|
||||||
|
$defaultReq = "";
|
||||||
|
|
||||||
|
// $defaultIgnoreEmpty is either true or false. If true, the script will ignore all empty fields
|
||||||
|
// and return only fields that contain data. Useful if you have a number optional fields and do not
|
||||||
|
// want to output them to the resulting email.
|
||||||
|
$defaultIgnoreEmpty = false;
|
||||||
|
|
||||||
|
// $smtpEnable enables or disables the SMTP sending method. enter 1 to turn it on or 0 to turn it off
|
||||||
|
// $smtpHost, $smtpUser, $smtpPass only need to be filled if $smtpEnable is set to 1
|
||||||
|
$smtpEnable = "0";
|
||||||
|
$smtpHost = "mail.server.com";
|
||||||
|
$smtpUser = "johndoe@domain.com";
|
||||||
|
$smtpPass = "passwerd";
|
||||||
|
|
||||||
|
// $errorTo is a valid email address that will receive a simple notification for each error that occurs.
|
||||||
|
// Leave blank to turn off. NOTE: this function does not support the SMTP sending method.
|
||||||
|
$errorTo = "";
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* DO NOT EDIT BELOW THIS LINE *
|
||||||
|
* unless you know what you are doing *
|
||||||
|
************************************************************************/
|
||||||
|
if ($defaultReq != "") $defaultReq .= ", recipient";
|
||||||
|
else $defaultReq = "recipient";
|
||||||
|
|
||||||
|
$referals = explode(",", $referals);
|
||||||
|
$excludeFields = explode(",", "recipient, ccrecipient, bccrecipient, subject, required, redirect, mailtemplate, mailtemplatehtml, submit, submit_x, submit_y, verification, ignoreempty, g-recaptcha-response, " . $excludeFields);
|
||||||
|
$srequired = explode(",", $defaultReq);
|
||||||
|
|
||||||
$errMsgStyle = "font-family: Arial;
|
$errMsgStyle = "font-family: Arial;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
@ -25,12 +75,12 @@
|
||||||
checkreferal();
|
checkreferal();
|
||||||
|
|
||||||
// Google reCaptcha v2
|
// Google reCaptcha v2
|
||||||
if(isset($conf['reCaptchaSecret'])){
|
if(isset($reCaptchaSecret)){
|
||||||
if(isset($_POST['g-recaptcha-response'])) $captcha=$_POST['g-recaptcha-response'];
|
if(isset($_POST['g-recaptcha-response'])) $captcha=$_POST['g-recaptcha-response'];
|
||||||
else errormsg("Verification failed. Please try again.");
|
else errormsg("Verification failed. Please try again.");
|
||||||
|
|
||||||
// post request to server
|
// post request to server
|
||||||
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($conf['reCaptchaSecret']) . '&response=' . urlencode($captcha);
|
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($reCaptchaSecret) . '&response=' . urlencode($captcha);
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
|
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
|
||||||
|
|
@ -48,23 +98,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
checkrequired();
|
checkrequired();
|
||||||
if(!validemail($conf['defaultFrom']) && !isset($_POST['email'])) bademail($conf['defaultFrom']);
|
if(!validemail($defaultFrom) && !isset($_POST['email'])) bademail($defaultFrom);
|
||||||
fillrecipients();
|
fillrecipients();
|
||||||
|
|
||||||
if(isset($_POST['subject']))
|
if(isset($_POST['subject']))
|
||||||
$subject = $_POST['subject'];
|
$subject = $_POST['subject'];
|
||||||
else
|
else
|
||||||
$subject = $conf['defaultSubject'];
|
$subject = $defaultSubject;
|
||||||
|
|
||||||
if(isset($_POST['ignoreempty']) && ($_POST('ignoreempty') === true || $_POST('ignoreempty') === false))
|
if(isset($_POST['ignoreempty']) && ($_POST('ignoreempty') === true || $_POST('ignoreempty') === false))
|
||||||
$ignoreempty = $_POST['ignoreempty'];
|
$ignoreempty = $_POST['ignoreempty'];
|
||||||
else
|
else
|
||||||
$ignoreempty = $conf['defaultIgnoreEmpty'];
|
$ignoreempty = $defaultIgnoreEmpty;
|
||||||
|
|
||||||
if(isset($_POST['email']) && trim($_POST['email']) != "")
|
if(isset($_POST['email']) && trim($_POST['email']) != "")
|
||||||
$fromemail = $_POST['email'];
|
$fromemail = $_POST['email'];
|
||||||
else
|
else
|
||||||
$fromemail = $conf['defaultFrom'];
|
$fromemail = $defaultFrom;
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['redirect']))
|
if(isset($_POST['redirect']))
|
||||||
|
|
@ -118,19 +168,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendit() {
|
function sendit() {
|
||||||
global $recipients, $subject, $message, $fromemail, $headers, $conf['smtpHost'], $conf['smtpUser'], $conf['smtpPass'], $conf['smtpEnable'];
|
global $recipients, $subject, $message, $fromemail, $headers, $smtpHost, $smtpUser, $smtpPass, $smtpEnable;
|
||||||
foreach($recipients as $to) {
|
foreach($recipients as $to) {
|
||||||
if($conf['smtpEnable'] == 1){
|
if($smtpEnable == 1){
|
||||||
require_once "Mail.php";
|
require_once "Mail.php";
|
||||||
|
|
||||||
$headers = array ('From' => $fromemail, 'To' => $to, 'Subject' => $subject);
|
$headers = array ('From' => $fromemail, 'To' => $to, 'Subject' => $subject);
|
||||||
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $conf['smtpUser'], 'password' => $conf['smtpPass']));
|
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $smtpUser, 'password' => $smtpPass));
|
||||||
|
|
||||||
$mail = $smtp->send($to, $headers, $message);
|
$mail = $smtp->send($to, $headers, $message);
|
||||||
|
|
||||||
if (PEAR::isError($mail)) errormsg($mail->getMessage());
|
if (PEAR::isError($mail)) errormsg($mail->getMessage());
|
||||||
}
|
}
|
||||||
elseif($conf['smtpEnable'] == 0){
|
elseif($smtpEnable == 0){
|
||||||
if(trim($to) != "")
|
if(trim($to) != "")
|
||||||
mail(trim($to), stripslashes($subject), stripslashes($message), $headers);
|
mail(trim($to), stripslashes($subject), stripslashes($message), $headers);
|
||||||
}
|
}
|
||||||
|
|
@ -183,8 +233,8 @@
|
||||||
|
|
||||||
function exclude($theVar) {
|
function exclude($theVar) {
|
||||||
$req = false;
|
$req = false;
|
||||||
global $conf['excludeFields'];
|
global $excludeFields;
|
||||||
foreach($conf['excludeFields'] as $field) {
|
foreach($excludeFields as $field) {
|
||||||
$field = trim($field);
|
$field = trim($field);
|
||||||
if(strcmp(strtolower($field), strtolower($theVar)) == 0)
|
if(strcmp(strtolower($field), strtolower($theVar)) == 0)
|
||||||
$req = true;
|
$req = true;
|
||||||
|
|
@ -192,9 +242,9 @@
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
function checkreferal() {
|
function checkreferal() {
|
||||||
global $conf['referrals'], $theDomain;
|
global $referals, $theDomain;
|
||||||
$valid = false;
|
$valid = false;
|
||||||
foreach($conf['referrals'] as $ref) {
|
foreach($referals as $ref) {
|
||||||
$ref = trim($ref);
|
$ref = trim($ref);
|
||||||
if(strcmp($theDomain, $ref) == 0) {
|
if(strcmp($theDomain, $ref) == 0) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
@ -205,7 +255,7 @@
|
||||||
badreferer($theDomain);
|
badreferer($theDomain);
|
||||||
}
|
}
|
||||||
function errormail($errormsg) {
|
function errormail($errormsg) {
|
||||||
if (validemail($conf['errorTo'])) mail($conf['errorTo'], 'Error on form', $errormsg, $headers);
|
if (validemail($errorTo)) mail($errorTo, 'Error on form', $errormsg, $headers);
|
||||||
}
|
}
|
||||||
function fillrecipients() {
|
function fillrecipients() {
|
||||||
global $recipients;
|
global $recipients;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue