1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00
php-e107/contact.php

181 lines
4.4 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* /contact.php
*
2006-12-02 04:36:16 +00:00
*/
2006-12-02 04:36:16 +00:00
require_once("class2.php");
2015-02-15 16:07:27 -08:00
define('e_HANDLER', "e107_handlers/");
2009-08-28 15:30:25 +00:00
// security image may be disabled by removing the appropriate shortcodes from the template.
require_once(e_HANDLER."secure_img_handler.php");
$sec_img = new secure_image;
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
2006-12-02 04:36:16 +00:00
require_once(HEADERF);
if (!vartrue($CONTACT_FORM))
{
if (file_exists(THEME."contact_template.php"))
{
2006-12-02 04:36:16 +00:00
require_once(THEME."contact_template.php");
2010-07-27 10:25:17 +00:00
}
else
{
// Redirect Page if no contact-form or contact-info is available.
if(($pref['sitecontacts']== e_UC_NOBODY) && trim(SITECONTACTINFO) == "")
{
e107::getRedirect()->redirect(e_BASE."index.php");
exit;
}
$CONTACT_FORM = e107::getCoreTemplate('contact','form'); // require_once(e_THEME."templates/contact_template.php");
2006-12-02 04:36:16 +00:00
}
}
2012-06-20 01:12:33 +00:00
if(isset($_POST['send-contactus']))
{
2006-12-02 04:36:16 +00:00
$error = "";
2009-12-10 21:03:56 +00:00
$sender_name = $tp->toEmail($_POST['author_name'],TRUE,'RAWTEXT');
2006-12-02 04:36:16 +00:00
$sender = check_email($_POST['email_send']);
2009-12-10 21:03:56 +00:00
$subject = $tp->toEmail($_POST['subject'],TRUE,'RAWTEXT');
$body = $tp->toEmail($_POST['body'],TRUE,'RAWTEXT');
2006-12-02 04:36:16 +00:00
// Check Image-Code
if (isset($_POST['rand_num']) && !$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
{
$error .= LANCONTACT_15."\\n";
}
// Check message body.
if(strlen(trim($_POST['body'])) < 15)
{
$error .= LANCONTACT_12."\\n";
}
// Check subject line.
2013-03-06 14:54:21 -08:00
if(varset($_POST['subject']) && strlen(trim($_POST['subject'])) < 2)
2006-12-02 04:36:16 +00:00
{
$error .= LANCONTACT_13."\\n";
}
if(!strpos(trim($_POST['email_send']),"@"))
{
$error .= LANCONTACT_11."\\n";
}
2006-12-02 04:36:16 +00:00
// Check email address on remote server (if enabled).
2009-12-10 21:03:56 +00:00
if ($pref['signup_remote_emailcheck'] && $error == '')
2006-12-02 04:36:16 +00:00
{
require_once(e_HANDLER."mail_validation_class.php");
2010-10-28 20:17:40 +00:00
list($adminuser,$adminhost) = explode('@', SITEADMINEMAIL, 2);
2006-12-02 04:36:16 +00:00
$validator = new email_validation_class;
$validator->localuser= $adminuser;
$validator->localhost= $adminhost;
$validator->timeout=3;
// $validator->debug=1;
// $validator->html_debug=1;
if($validator->ValidateEmailBox($sender) != 1)
{
$error .= LANCONTACT_11."\\n";
}
}
// No errors - so proceed to email the admin and the user (if selected).
2006-12-02 04:36:16 +00:00
if(!$error)
{
$body .= "\n\nIP:\t".e107::getIPHandler()->getIP(TRUE)."\n";
if (USER)
{
2006-12-02 04:36:16 +00:00
$body .= "User:\t#".USERID." ".USERNAME."\n";
}
2006-12-02 04:36:16 +00:00
if(!$_POST['contact_person'] && isset($pref['sitecontacts'])) // only 1 person, so contact_person not posted.
{
if($pref['sitecontacts'] == e_UC_MAINADMIN)
{
$query = "user_perms = '0' OR user_perms = '0.' ";
}
elseif($pref['sitecontacts'] == e_UC_ADMIN)
{
$query = "user_admin = 1 ";
}
else
{
$query = "FIND_IN_SET(".$pref['sitecontacts'].",user_class) ";
2006-12-02 04:36:16 +00:00
}
}
else
{
$query = "user_id = ".intval($_POST['contact_person']);
2006-12-02 04:36:16 +00:00
}
if($sql -> db_Select("user", "user_name,user_email",$query." LIMIT 1"))
{
$row = $sql -> db_Fetch();
$send_to = $row['user_email'];
$send_to_name = $row['user_name'];
}
else
{
$send_to = SITEADMINEMAIL;
$send_to_name = ADMIN;
}
require_once(e_HANDLER."mail.php");
$message = (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
if(isset($pref['contact_emailcopy']) && $pref['contact_emailcopy'] && $_POST['email_copy'] == 1){
sendemail($sender,"[".SITENAME."] ".$subject, $body,ADMIN,$sender,$sender_name);
}
$ns -> tablerender('', $message);
require_once(FOOTERF);
exit;
}
else
{
message_handler("P_ALERT", $error);
}
}
2013-04-30 03:07:24 -07:00
if(SITECONTACTINFO)
2006-12-02 04:36:16 +00:00
{
2013-04-30 03:07:24 -07:00
if(!isset($CONTACT_INFO))
{
$CONTACT_INFO = e107::getCoreTemplate('contact','info');
}
$text = $tp->parseTemplate($CONTACT_INFO, TRUE, vartrue($contact_shortcodes));
2006-12-02 04:36:16 +00:00
$ns -> tablerender(LANCONTACT_01, $text,"contact");
}
if(isset($pref['sitecontacts']) && $pref['sitecontacts'] != 255)
{
2012-06-20 01:12:33 +00:00
$contact_shortcodes = e107::getScBatch('contact');
// Wrapper support
$contact_shortcodes->wrapper('contact/form');
2006-12-02 04:36:16 +00:00
$text = $tp->parseTemplate($CONTACT_FORM, TRUE, $contact_shortcodes);
if(trim($text) != "")
{
$ns -> tablerender(LANCONTACT_02, $text, "contact");
}
}
require_once(FOOTERF);
exit;
?>