Fix for #55: HTTPS URLs in the contact form are now handled correctly.
This commit is contained in:
parent
ddc2af887b
commit
eb20caebc5
159
contact.php
159
contact.php
@ -1,114 +1,97 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'defaults.php';
|
require_once 'defaults.php';
|
||||||
require_once (INCLUDES_DIR.'includes.php');
|
require_once (INCLUDES_DIR . 'includes.php');
|
||||||
require SMARTY_DIR . 'SmartyValidate.class.php';
|
require SMARTY_DIR . 'SmartyValidate.class.php';
|
||||||
|
|
||||||
|
function contact_form_validate() {
|
||||||
|
$arr ['version'] = system_ver();
|
||||||
|
$arr ['name'] = $_POST ['name'];
|
||||||
|
|
||||||
function contact_form_validate() {
|
if (!empty($_POST ['email']))
|
||||||
|
($arr ['email'] = $_POST ['email']);
|
||||||
|
if (!empty($_POST ['url']))
|
||||||
|
($arr ['url'] = $_POST ['url']);
|
||||||
|
$arr ['content'] = $_POST ['content'];
|
||||||
|
|
||||||
|
$arr ['ip-address'] = utils_ipget();
|
||||||
|
|
||||||
$arr['version'] = system_ver();
|
if (apply_filters('comment_validate', true, $arr))
|
||||||
$arr['name'] = $_POST['name'];
|
return $arr;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST['email']))
|
function contact_form() {
|
||||||
($arr['email'] = $_POST['email']);
|
global $smarty, $lang, $fp_config;
|
||||||
if (!empty($_POST['url']))
|
|
||||||
($arr['url'] = $_POST['url']);
|
|
||||||
$arr['content'] = $_POST['content'];
|
|
||||||
|
|
||||||
$arr['ip-address'] = utils_ipget();
|
if (empty($_POST)) {
|
||||||
|
|
||||||
if (apply_filters('comment_validate', true, $arr))
|
|
||||||
return $arr;
|
|
||||||
else return false;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function contact_form() {
|
|
||||||
|
|
||||||
global $smarty, $lang, $fp_config;
|
|
||||||
|
|
||||||
if(empty($_POST)) {
|
|
||||||
|
|
||||||
$smarty->assign('success', system_geterr('contact'));
|
|
||||||
$smarty->assign_by_ref('panelstrings', $lang['contact']);
|
|
||||||
|
|
||||||
|
$smarty->assign('success', system_geterr('contact'));
|
||||||
|
$smarty->assign_by_ref('panelstrings', $lang ['contact']);
|
||||||
|
|
||||||
// new form, we (re)set the session data
|
// new form, we (re)set the session data
|
||||||
SmartyValidate::connect($smarty, true);
|
SmartyValidate::connect($smarty, true);
|
||||||
// register our validators
|
// register our validators
|
||||||
SmartyValidate::register_validator('name', 'name', 'notEmpty', false, false, 'trim');
|
SmartyValidate::register_validator('name', 'name', 'notEmpty', false, false, 'trim');
|
||||||
SmartyValidate::register_validator('email', 'email', 'isEmail', true, false, 'trim');
|
SmartyValidate::register_validator('email', 'email', 'isEmail', true, false, 'trim');
|
||||||
SmartyValidate::register_validator('www', 'url', 'isURL', true, false, 'trim');
|
SmartyValidate::register_validator('www', 'url', 'isURL', true, false, 'trim');
|
||||||
SmartyValidate::register_validator('content', 'content', 'notEmpty', false, false);
|
SmartyValidate::register_validator('content', 'content', 'notEmpty', false, false);
|
||||||
|
} else {
|
||||||
|
utils_nocache_headers();
|
||||||
|
// validate after a POST
|
||||||
|
SmartyValidate::connect($smarty);
|
||||||
|
|
||||||
|
// add http to url if not given
|
||||||
|
if (!empty($_POST ['url']) && strpos($_POST ['url'], 'http://') === false && strpos($_POST ['url'], 'https://') === false)
|
||||||
|
$_POST ['url'] = 'http://' . $_POST ['url'];
|
||||||
|
|
||||||
|
// custom hook here!!
|
||||||
|
// we'll use comment actions, anyway
|
||||||
|
if (SmartyValidate::is_valid($_POST) && $arr = contact_form_validate()) {
|
||||||
|
|
||||||
|
$msg = "Name: \n{$arr['name']} \n\n";
|
||||||
|
|
||||||
|
if (isset($arr ['email']))
|
||||||
|
$msg .= "Email: {$arr['email']}\n\n";
|
||||||
|
if (isset($arr ['url']))
|
||||||
|
$msg .= "WWW: {$arr['url']}\n\n";
|
||||||
|
$msg .= "Content:\n{$arr['content']}\n";
|
||||||
|
|
||||||
|
$success = @utils_mail((isset($arr ['email']) ? $arr ['email'] : $fp_config ['general'] ['email']), "Contact sent through {$fp_config['general']['title']} ", $msg);
|
||||||
|
|
||||||
|
system_seterr('contact', $success ? 1 : -1);
|
||||||
|
utils_redirect(basename(__FILE__));
|
||||||
} else {
|
} else {
|
||||||
utils_nocache_headers();
|
$smarty->assign('values', $_POST);
|
||||||
// validate after a POST
|
|
||||||
SmartyValidate::connect($smarty);
|
|
||||||
|
|
||||||
if (!empty($_POST['url']) && strpos($_POST['url'], 'http://')===false) $_POST['url'] = 'http://'.$_POST['url'];
|
|
||||||
|
|
||||||
|
|
||||||
// custom hook here!!
|
|
||||||
// we'll use comment actions, anyway
|
|
||||||
if(SmartyValidate::is_valid($_POST) && $arr=contact_form_validate()) {
|
|
||||||
|
|
||||||
$msg = "Name: \n{$arr['name']} \n\n";
|
|
||||||
|
|
||||||
if (isset($arr['email']))
|
|
||||||
$msg .= "Email: {$arr['email']}\n\n";
|
|
||||||
if (isset($arr['url']))
|
|
||||||
$msg .= "WWW: {$arr['url']}\n\n";
|
|
||||||
$msg .= "Content:\n{$arr['content']}\n";
|
|
||||||
|
|
||||||
$success = @utils_mail(
|
|
||||||
(
|
|
||||||
isset($arr['email'])?
|
|
||||||
$arr['email']
|
|
||||||
:
|
|
||||||
$fp_config['general']['email']
|
|
||||||
),
|
|
||||||
"Contact sent through {$fp_config['general']['title']} ", $msg );
|
|
||||||
|
|
||||||
system_seterr('contact', $success? 1 : -1);
|
|
||||||
utils_redirect(basename(__FILE__));
|
|
||||||
} else {
|
|
||||||
$smarty->assign('values', $_POST);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function contact_main() {
|
||||||
|
global $smarty;
|
||||||
|
|
||||||
function contact_main() {
|
$lang = lang_load('contact');
|
||||||
global $smarty;
|
|
||||||
|
|
||||||
$lang = lang_load('contact');
|
$smarty->assign('subject', $lang ['contact'] ['head']);
|
||||||
|
$smarty->assign('content', 'shared:contact.tpl');
|
||||||
|
contact_form();
|
||||||
|
}
|
||||||
|
|
||||||
$smarty->assign('subject', $lang['contact']['head']);
|
function contact_display() {
|
||||||
$smarty->assign('content', 'shared:contact.tpl');
|
global $smarty;
|
||||||
contact_form();
|
|
||||||
|
|
||||||
}
|
contact_main();
|
||||||
|
|
||||||
function contact_display() {
|
theme_init($smarty);
|
||||||
global $smarty;
|
|
||||||
|
|
||||||
contact_main();
|
$smarty->display('default.tpl');
|
||||||
|
|
||||||
theme_init($smarty);
|
unset($smarty);
|
||||||
|
|
||||||
$smarty->display('default.tpl');
|
do_action('shutdown');
|
||||||
|
}
|
||||||
|
|
||||||
unset($smarty);
|
system_init();
|
||||||
|
contact_display();
|
||||||
do_action('shutdown');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
system_init();
|
|
||||||
contact_display();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user