Не уверен какой точно из них нужен, там их несколько
contact.php:
1.
PHP код:
<?php
/**
* @author Eric Sizemore <stu@DNSPortfolio.com>
* @package DNS Portfolio
* @link www.DNSPortfolio.com
* @version 1.6.2
* @copyright (C) 2010 - 2011 Stu Buckingham
* @license http://www.DNSPortfolio.com/license.html GNU Public License
* @file ./contact.php
*/
// for javascript in header file
define('IN_CONTACT', true);
define('IN_DNP', true);
require_once('./includes/global.php');
// ################################################################
$mode = sanitize($_GET['mode']);
$mode = (!in_array($mode, array('general', 'domain'))) ? 'general' : $mode;
// Are we contacting about a certain domain?
if ($mode == 'domain')
{
// Valid ID?
$domainid = (is_string($_GET['d'])) ? sanitize($_GET['d']) : intval($_GET['d']);
if (!is('domain', $domainid))
{
redirect('index.php');
}
// Pull the domain and it's status.
$getdomain = get_value('contact', $domainid);
if (count($getdomain) == 0)
{
redirect('index.php');
}
$domain = $getdomain['domain'];
$status = $getdomain['status'];
unset($getdomain);
// Has the domain been sold, or is it not for sale?
if (in_array($status, array('Sold', 'Not For Sale')))
{
redirect('index.php');
}
}
$result = '';
// ################################################################
// Process the form and send the email..
require_once('./includes/recaptcha.class.php');
$recaptcha = recaptcha::getInstance();
$recaptcha_error = NULL;
if (!empty($_POST['submit']))
{
$name = sanitize($_POST['sender_name']);
$email = sanitize($_POST['sender_email']);
// If this is concerning a domain, we'll check for an offer.
if ($mode == 'domain')
{
$offer = sanitize(str_replace($config->get('currency'), '', $_POST['sender_offer']));
$offer = preg_replace('#\.[0-9]{2}$#', '', $offer);
$offer = preg_replace('#([^0-9,]+)#', '', $offer);
}
else
{
// Otherwise, we need an email subject.
$subject = sanitize($_POST['sender_subject']);
}
// Email body/message...
$message = str_replace("\r\n", "\n", $_POST['sender_message']);
$message = wordwrap(sanitize($message, false), 75);
// reCAPTCHA - Just say no, to spam. :)
$recaptcha_challenge = sanitize($_POST['recaptcha_challenge_field']);
$recaptcha_response = sanitize($_POST['recaptcha_response_field']);
/**
* Create a session value for name, email, and message.
* This way, if there's an error, a user won't lose what they've entered.
*/
$_SESSION['form'] = array(
'name' => $name,
'email' => $email,
'message' => $message
);
// Holds any errors that may happen with entered data
$errors = array();
// We need to make sure all data is there/valid...
if (empty($name) OR is('injection', $name))
{
$errors[] = 'Your name is required.';
}
if (empty($email))
{
$errors[] = 'Your email is required.';
}
if (empty($message))
{
$errors[] = 'A message is required.';
}
if (!is('email', $email) OR is('injection', $email))
{
$errors[] = 'Email is invalid.';
}
if ($mode == 'general' AND empty($subject))
{
$errors[] = 'A subject is required.';
}
if (is('spam', $message))
{
$errors[] = 'Sorry, but your message seemed a bit like spam.';
}
if (count($errors) > 0)
{
$result .= 'The following errors occurred:<br /><ul>';
foreach ($errors AS $error)
{
$result .= "<li>$error</li>\n";
}
$result .= '</ul>';
unset($errors);
}
else
{
$resp = $recaptcha->check_answer(get_ip(), $recaptcha_challenge, $recaptcha_response);
if (!$resp->is_valid)
{
$recaptcha_error = $resp->error;
$result .= 'reCAPTCHA: Incorrect. Try again.';
}
else
{
$recaptcha_error = NULL;
$params = array(
'name' => $name,
'email' => $email,
'ip' => get_ip(),
'message' => $message
);
if ($mode == 'domain')
{
$params['domain'] = $domain;
$params['offer'] = (empty($offer) ? 'n/a' : $offer);
}
else
{
$params['subject'] = $subject;
}
require_once('./includes/emailer.class.php');
$emailer = emailer::getInstance();
$emailer->set_params($config->get('contactemail'), $email, ($mode == 'domain' ? "Domain Inquiry: $domain" : "Inquiry: $subject"));
$emailer->use_template($params, ($mode == 'domain' ? 'email.tpl' : 'email_general.tpl'));
if ($emailer->send())
{
$result .= "Thank you, $name, your inquiry was sent.";
// Reset the session array
$_SESSION['form'] = array(
'name' => '',
'email' => '',
'message' => ''
);
}
else
{
$result .= 'Seems to have been a problem sending the email. Please try again.';
}
}
}
}
else
{
$_SESSION['form'] = array(
'name' => '',
'email' => '',
'message' => ''
);
}
// ################################################################
// Output page
$pagetitle = ($mode == 'domain') ? "Inquiring about $domain" : 'General Inquiry';
if ($mode == 'domain')
{
include("$template/contact.php");
}
else
{
include("$template/contact_general.php");
}
?>
2.
PHP код:
<?php include ("header.php"); ?>
<div id="wrapper">
<div id="left">
<div class="content">
</div> <!-- end content -->
</div> <!-- end left -->
<div id="center">
<div class="content">
<h3>>Contact</h3>
<p>Please use the following form to send us an e-mail. We will try to respond as soon as possible.</p>
<br />
<?php if ($result != ''): ?>
<div id="result"><?php echo $result; ?></div>
<br />
<?php endif; ?>
<form action="./contact.php?mode=general" method="post" style="display: inline;" onsubmit="return validate_form('general');">
<table cellspacing="0">
<tbody>
<tr class="odd">
<td class="one"><label for="sender_name">Name:*</label></td>
<td class="two"><input type="text" name="sender_name" id="sender_name" maxlength="100" value="<?php echo $_SESSION['form']['name']; ?>" /></td>
</tr>
<tr class="even">
<td class="one"><label for="sender_email">E-mail:*</label></td>
<td class="two"><input type="text" name="sender_email" id="sender_email" maxlength="100" value="<?php echo $_SESSION['form']['email']; ?>" /></td>
</tr>
<tr class="odd">
<td class="one"><strong>Domain:</strong></td>
<td class="two"><?php echo $domain; ?></td>
</tr>
<tr class="even">
<td class="one"><label for="sender_offer">Offer:</label></td>
<td class="two"><input type="text" name="sender_offer" id="sender_offer" maxlength="10" /> <small>(optional - only <code>0-9</code> and <code>,</code> accepted. Eg: 1,000 (<?php echo $config->get('currency'); ?>1,000))</small></td>
</tr>
<tr class="odd">
<td class="one"><label for="sender_subject">Subject:*</label></td>
<td class="two">
<select name="sender_subject" id="sender_subject">
<option label="Domain Purchase Offer" value="Domain Purchase Offer">Domain Purchase Offer</option>
<!-- <option label="Advertising" value="Advertising">Advertising</option>
<option label="Site Problem" value="Site Problem">Site Problem</option>
<option label="Suggestions" value="Suggestions">Suggestions</option> -->
<option label="Other" value="Other">Other</option>
</select>
</td>
</tr>
<tr class="even">
<td valign="top" class="one"><label for="sender_message">Message:*</label></td>
<td class="two"><textarea name="sender_message" id="sender_message" rows="4" cols="35"><?php echo $_SESSION['form']['message']; ?></textarea></td>
</tr>
<tr class="odd">
<td valign="top" colspan="2" class="one"><?php echo $recaptcha->get_html($recaptcha_error); ?></td>
</tr>
<tr class="even">
<td colspan="2" class="two"><input type="submit" name="submit" value="Submit" class="button" /></td>
</tr>
</tbody>
</table>
</form>
</div> <!-- end content -->
</div> <!-- end center -->
<div id="right">
<div class="content">
</div> <!-- end content -->
</div> <!-- end right -->
</div><!-- end #wrapper -->
<?php include ("footer.php"); ?>
добавлено через 1 час 13 минут
Проблема решена
Прочел на форуме разработчика.
niceweb, вам спасибо за желание помочь
добавлено через 2 часа 17 минут
Теперь другой вопрос
Не воспринимает русский шрифт, скрипт буржуйский и все в
utf-8. Если писать кириллицей то приходит пустота, а имя вводишь на русском, так ругается, что "не введено имя". Можно это как-то все дело перевести на
windows-1251?