this is another one : [MOD] Contact Form (by vividviews)
>> 01 file to modify from 4images root:
[change]
includes/functions.php >> 04 new file to create from 4images root:
[new]
contact.php[new]
templates/<yourtemplate>/contact.html[new]
templates/<yourtemplate>/contact_mailform.html[new]
lang/<your_language_dir>/email/contactform_message.htmlFirst, backup your files.------ Installation ------ STEP 1:open /includes/functions.php
find :
function check_email($email) {
return (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $email)) ? 1 : 0;
}
replace by:
//-------------------------------------------[ [Mod] Contact form]
/*
function check_email($email) {
return (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $email)) ? 1 : 0;
}
*/
function check_email($email) {
// original code return (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $email)) ? 1 : 0;
return(!MailChek($email, 2)); // Mod
}
function MailChek($Addr, $Level, $Timeout = 15000) {
// Valid Top-Level Domains
$gTLDs = "com:net:org:edu:gov:mil:int:arpa:aero:biz:coop:info:museum:name:";
$CCs = "ad:ae:af:ag:ai:al:am:an:ao:aq:ar:as:at:au:aw:az:ba:bb:bd:be:bf:".
"bg:bh:bi:bj:bm:bn:bo:br:bs:bt:bv:bw:by:bz:ca:cc:cf:cd:cg:ch:ci:".
"ck:cl:cm:cn:co:cr:cs:cu:cv:cx:cy:cz:de:dj:dk:dm:do:dz:ec:ee:eg:".
"eh:er:es:et:fi:fj:fk:fm:fo:fr:fx:ga:gb:gd:ge:gf:gh:gi:gl:gm:gn:".
"gp:gq:gr:gs:gt:gu:gw:gy:hk:hm:hn:hr:ht:hu:id:ie:il:in:io:iq:ir:".
"is:it:jm:jo:jp:ke:kg:kh:ki:km:kn:kp:kr:kw:ky:kz:la:lb:lc:li:lk:".
"lr:ls:lt:lu:lv:ly:ma:mc:md:mg:mh:mk:ml:mm:mn:mo:mp:mq:mr:ms:mt:".
"mu:mv:mw:mx:my:mz:na:nc:ne:nf:ng:ni:nl:no:np:nr:nt:nu:nz:om:pa:".
"pe:pf:pg:ph:pk:pl:pm:pn:pr:pt:pw:py:qa:re:ro:ru:rw:sa:sb:sc:sd:".
"se:sg:sh:si:sj:sk:sl:sm:sn:so:sr:st:su:sv:sy:sz:tc:td:tf:tg:th:".
"tj:tk:tm:tn:to:tp:tr:tt:tv:tw:tz:ua:ug:uk:um:us:uy:uz:va:vc:ve:".
"vg:vi:vn:vu:wf:ws:ye:yt:yu:za:zm:zr:zw:";
// The countries can have their own 'TLDs', e.g. mydomain.com.au
$cTLDs = "com:net:org:edu:gov:mil:co:ne:or:ed:go:mi:aero:biz:coop:info:museum:name:";
$fail = 0;
// Shift the address to lowercase to simplify checking and trim
$Addr = trim(strtolower($Addr));
// Check for spaces
if (ereg(" ", $Addr)) $fail = 1;
// Split the Address into user and domain parts
$UD = explode("@", $Addr);
if (sizeof($UD) != 2 || !$UD[0]) $fail = 1;
// Split the domain part into its Levels
$Levels = explode(".", $UD[1]); $sLevels = sizeof($Levels);
if (!$Levels[0] || !$Levels[1]) $fail = 1;
// Get the TLD, strip off trailing ] } ) > and check the length
$tld = $Levels[$sLevels-1];
$tld = ereg_replace("[>)}]$|]$", "", $tld);
if (strlen($tld) < 2
|| (strlen($tld) > 3 && !ereg(":$tld:", ":arpa:aero:coop:info:museum:name:"))) $fail = 1;
$Level--;
// If the string after the last dot isn't in the generic TLDs or country codes, it's invalid.
if ($Level && !$fail) {
$Level--;
if (!ereg($tld.":", $gTLDs) && !ereg($tld.":", $CCs)) $fail = 2;
}
// If it's a country code, check for a country TLD; add on the domain name.
if ($Level && !$fail) {
$cd = $sLevels - 2; $domain = $Levels[$cd].".".$tld;
if (ereg($Levels[$cd].":", $cTLDs)) { $cd--; $domain = $Levels[$cd].".".$domain; }
}
// See if there's an MX record for the domain
if ($Level && !$fail) {
$Level--;
if (!getmxrr($domain, $mxhosts, $weight)) $fail = 3;
}
// Attempt to connect to port 25 on an MX host
if ($Level && !$fail) {
$Level--;
while (!$sh && list($nul, $mxhost) = each($mxhosts))
$sh = fsockopen($mxhost, 25);
if (!$sh) $fail=4;
}
// See if anyone answers
if ($Level && !$fail) {
$Level--;
set_socket_blocking($sh, false);
$out = ""; $t = 0;
while ($Timeout-- && !$out)
$out = fgets($sh, 256);
if (!ereg("^220", $out)) $fail = 5;
}
if ($sh) fclose($sh);
return $fail;
} //MailChek
//-------------------------------------------[/[Mod] Contact form]
STEP 2:create a new file
contact.php in 4images root with this:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: member.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = "contact";
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('GET_USER_ONLINE', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
include(ROOT_PATH.'includes/page_header.php');
if ($action == "") {
$action = "mailform";
}
$content = "";
$txt_clickstream = "Contact";
$sendprocess = 0;
$user_id = 1; // CHANGE THIS - Set this to your user id
if ($action == "emailSiteOwner") {
$user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? intval($HTTP_POST_VARS[URL_USER_ID]) : 1; // CHANGE THIS - 1 is hardcoded to my user id
$error = 0;
$sender_name = stripslashes(trim($HTTP_POST_VARS['sender_name']));
$sender_email = stripslashes(trim($HTTP_POST_VARS['sender_email']));
$subject = stripslashes(trim($HTTP_POST_VARS['subject']));
$message = stripslashes(trim($HTTP_POST_VARS['message']));
if ($sender_name == "" || $sender_email == "" || $subject == "" || $message == "") {
$msg = $lang['lostfield_error'];
$sendprocess = 1;
$error = 1;
}
if(!$error && $sender_email != "" && MailChek($sender_email, 2)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$sendprocess = 1;
$error = 1;
}
if (!$error) {
$user_row = get_user_info($user_id);
$sender_user_name = $sender_name;
$sender_user_email = $sender_email;
// Start Emailer
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_from($sender_user_email, $sender_user_name);
$site_email->set_to("your_mail_adresse@domain.com"); // CHANGE THIS - Set to your email address
$site_email->set_subject("Contact Form: ".$subject); // CHANGE THIS - Set this to whatever prefix you want to appear in the email subject
$site_email->register_vars(array(
"sender_user_name" => $sender_user_name,
"sender_user_email" => $sender_user_email,
"message" => $message,
"site_name" => $config['site_name'],
"site_email" => $config['site_email']
));
$site_email->set_body("contactform_message", $config['language_dir']);
$site_email->send_email();
$msg = $lang['emailuser_success'];
// header("Location: ".ROOT_PATH);
}
else {
$action = "mailform";
}
}
if ($action == "mailform") {
if (!$sendprocess) {
$subject = "";
$message = "";
}
$sender_name = ($user_info['user_level'] != GUEST) ? $user_info['user_name'] : "";
$sender_email = ($user_info['user_level'] != GUEST) ? $user_info['user_email'] : "";
$site_template->register_vars(array(
"sender_name" => $sender_name,
"sender_email" => $sender_email,
"subject" => htmlspecialchars($subject),
"message" => htmlspecialchars($message),
"lang_send_email_to" => $lang['send_email_to'],
"lang_subject" => $lang['subject'],
"lang_message" => $lang['message'],
"lang_submit" => $lang['submit'],
"lang_reset" => $lang['reset']
));
$content = $site_template->parse_template("contact_mailform");
}
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"content" => $content,
"msg" => $msg,
"clickstream" => $clickstream,
"lang_control_panel" => $lang['control_panel']
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
STEP 3:First method:(if you don't want to use my template, go to the second method)
create a new file
contact.html in
your template dir with this code:
{header}
<table width="800" border="0" cellspacing="0" cellpadding="0" align="center" background="{template_url}/images/logo.gif">
<tr>
<td width="800" height="52" align="center">
<table cellpadding="0" cellspacing="0" width="800" height="50" background="{template_url}/images/logo2.gif" width"180" height="50">
<tr>
<td width="199">
<p align="right"> </p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="bordercolor" width="800">
<table width="800" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="tablebgcolor">
<table width="638" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="23">
<table width="800" border="0" cellspacing="0" cellpadding="0" background="{template_url}/images/navbar.gif" height="23">
<tr>
<td><img src="{template_url}/images/spacer.gif" width="4" height="4" alt="" />{clickstream}</td>
<td align="right">
<a href="{url_top_images}"><b>{lang_top_images}</b></a>
<a href="{url_new_images}"><b>{lang_new_images}</b></a><b>
<a href="{url_search}">{lang_search}</a>
</b>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="801" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" class="row2" valign="top">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head2" height="20" background="{template_url}/images/cat.gif"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_registered_user}</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td align="center" class="row1">{user_box}</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
</table>
{if random_image} <table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head2" height="20" background="{template_url}/images/cat.gif"> <img src="../../default/{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_random_image}</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="../../default/{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td align="center" class="row1">
<br />
{random_image}
<br />
<br />
</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="../../default/{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
</table>
{endif random_image}
</td>
<td width="1" class="bordercolor" valign="top"><img src="{template_url}/images/spacer.gif" width="1" height="1" alt="" /></td>
<td width="18" valign="top"><img src="{template_url}/images/spacer.gif" width="18" height="18" alt="" /></td>
<td width="610" valign="top"><br />
<span class="title">{site_name}</span><br />
<hr size="1" />
{if msg}<div class="msg">{msg}</div>{endif msg}
<br />
{content}
<p> </p>
<p> </p>
</td>
<td width="19" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="19" height="19" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="803" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="804" border="0" cellspacing="0" cellpadding="0" class="tablebottom">
<tr>
<td width="6"><img src="{template_url}/images/footer_left.gif" width="6" height="19" alt="" /></td>
<td width="470"> </td>
<td width="320"> </td>
<td width="6"><img src="{template_url}/images/footer_right.gif" width="6" height="19" alt="" /></td>
</tr>
</table>
</td>
</tr>
</table>
{footer}
OK as you can see it's my template !!! to use
your template follow this steps :
Second method:open
error.html in
your template dir (this is an example, you can choose another file... but this file is the easiest to modify
)
find this :
<b class="title">{lang_error}</b>
<hr size="1" />
<p>{error_msg}</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>{category_dropdown_form}</td>
<td align="right">{setperpage_dropdown_form}</td>
</tr>
</table>
and replace by:
<span class="title">{site_name}</span><br />
<hr size="1" />
{if msg}<div class="msg">{msg}</div>{endif msg}
<br />
{content}
and now save this modified file as a new file called
contact.html.
STEP 4:create a new file
contact_mailform.html in
your template dir with this code:
<table width="100%" class="box">
<thead>
<tr>
<th class="head2">Contact The Web Site Owner</th>
</tr>
</thead>
<tr>
<td><div style="position:relative;">
<table width="100%" cellpadding="6" cellspacing="2" border="0">
<FORM name="contactForm" action="{url_contact}" METHOD="POST">
<tr>
<td align="right" valign="middle"><b>Your Name:</b></td>
<td align="left"><input name="sender_name" type="text" id="sender_name" tabindex="1" value="{sender_name}" size="40" maxlength="50">
</td>
</tr>
<tr>
<td align="right" valign="middle"><b>Your Email:</b></td>
<td align="left"><input name="sender_email" type="text" id="sender_email" tabindex="2" value="{sender_email}" size="40" maxlength="50">
</td>
</tr>
<tr>
<td align="right" valign="middle"><b>{lang_subject}</b></td>
<td align="left"><input name="subject" type="text" id="subject" tabindex="3" value="{subject}" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>{lang_message}</b></td>
<td align="left" valign="top"><textarea name="message" cols="60" rows="10" wrap="VIRTUAL" id="message" tabindex="4">{message}</textarea>
</td>
</tr>
<tr>
<td> </td>
<td align="left"><input type="hidden" name="action" value="emailSiteOwner" />
<input type="hidden" name="user_id" value="{user_id}" /> <input tabindex="5" type="submit" name="submit" value="{lang_submit}" class="button" style="margin-right:10px; ">
<input tabindex="6" type="reset" name="reset" value="{lang_reset}" class="button">
</td>
</tr>
<script type="text/javascript">
// set focus to form field
cForm = document.getElementById("contactForm");
cForm.sender_name.focus();
</script>
</form>
</table>
<!-- <address style="position:absolute; top: 3px; right: 25px;">
My Contact Name<br>
My Contact Street<br>
My Contact City, Postal Code
</address> -->
</div>
</td>
</tr>
</table>
STEP 5:create a new file
contactform_message.html in
/lang/<your_language_dir>/email/ with this code:
This is an email sent by {sender_user_name} ({sender_user_email}) thanks to the contact form.
If this message is spam, contains abusive or other comments you find offensive please contact the webmaster at:
{site_email}
Message sent to you follows:
-------------------------------------------
{message}
STEP 6:open
user_logininfo.html in
your template dirfind :
» <a href="{url_control_panel}">{lang_control_panel}</a><br />
add above :
» <a href="{site_url}/4images/contact.php">Contact Form</a><br />
you can do almost the same modification with
user_loginform.html if you want to let anyone on your site to contact your site admistrators.
------ End of Installation ------ Have fun!