Da diesen Mod keiner mehr supportet, hab ich ihn überarbeitet.
incl. mail format check and captcha.
Optional: send email to images owner...
Optional: captcha can mathematic...
when a user is logged on, he can choose the admin he wants to write an email, (idea from
hereDemo: demo.vienna-pictures.com1.) create a new file called "contact.php" and store in you root:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: contact.php *
* Copyright: (C) 2002 - 2010 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.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";
}
$txt_clickstream = $lang['contact'];
$content = "";
$sendprocess = 0;
if ($action == "emailSiteOwner") {
$error = 0;
$mail_to = (isset($_POST['emails'])) ? $_POST['emails'] : $config['site_email'];
$sender_name = stripslashes(trim($_POST['sender_name']));
$sender_email = stripslashes(trim($_POST['sender_email']));
$subject = stripslashes(trim($_POST['subject']));
$message = stripslashes(trim($_POST['message']));
$captcha = (isset($_POST['captcha'])) ? un_htmlspecialchars(trim($_POST['captcha'])) : "";
if ($sender_name == "" || $sender_email == "" || $subject == "" || $message == "") {
$msg = $lang['lostfield_error'];
$sendprocess = 1;
$error = 1;
}
$check = "/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/";
if(!isset($sender_email) OR $sender_email == "" OR !preg_match($check,$sender_email))
{
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$sendprocess = 1;
$error = 1;
}
if ($captcha_enable_contact && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
if (!$error) {
$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($mail_to);
$site_email->set_subject($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->set_body("mailform_message", $config['language_dir']);
$site_email->send_email();
$msg = $lang['emailuser_success'];
}
else {
$action = "mailform";
}
}
if ($action == "mailform") {
if (!$sendprocess) {
$subject = "";
$message = "";
}
if ($user_info['user_level'] != GUEST) {
$select = "<tr>";
$select .= "<td align=\"right\" valign=\"middle\"><b>".$lang['mail_to']."</b></td>";
$sql = "SELECT user_id,user_level,user_name,user_email,user_allowemails
FROM ".USERS_TABLE."
WHERE user_level = 9 AND user_allowemails = 1
ORDER BY user_name ASC ";
$result = $site_db->query($sql);
$select .= "<td align=\"left\"><select class=\"input\" name=\"emails\" >\n";
$select .= "<option value=\"".$config['site_email']."\" class=\"dropdownmarker\">".$lang['userlevel_admin']."</option>\n";
while ($row = $site_db->fetch_array($result)) {
$select .= "<option value=\"".$row['user_email']."\">» ".format_text($row['user_name'], 2)." (".$row['user_email'].")</option>\n";
}
$select .= "</select>\n";
$select .= " </td>";
$select .= "</tr>";
$site_template->register_vars("select",$select);
}
$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),
"captcha_contact" => (bool)$captcha_enable_contact,
"lang_captcha" => $lang['captcha'],
"lang_captcha_desc" => $lang['captcha_desc'],
"lang_mail_custom_text" => $lang['mail_custom_text'],
"lang_contact" => $lang['contact'],
"lang_mail_to" => $lang['mail_to'],
"lang_your_name" => $lang['your_name'],
"lang_your_mail" => $lang['your_mail'],
"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');
?>
2.) search in includes/page_header.php
$site_template->register_vars(array(
"home_url" => ROOT_PATH,
insert below:
"lang_contact" => $lang['contact'],
3.) insert in lang/deutsch/main.php
$lang['contact'] = "Kontakt";
$lang['mail_custom_text'] = " Sollten sie fragen zu eines der Bilder haben,<br>können Sie hier mit mir in Kontakt treten.<br><br>Rembrandt";
$lang['mail_to'] = "An:";
$lang['your_name'] = "Ihr Name:";
$lang['your_mail'] = "Ihre Email:";
lang/english/main.php
$lang['contact'] = "Contact";
$lang['mail_custom_text'] = " Have you any questions to the images, contact me.<br><br>Rembrandt";
$lang['mail_to'] = "To:";
$lang['your_name'] = "Your Name:";
$lang['your_mail'] = "Your Email:";
4.) search in templates/yourTemplates'/user_logininfo.html:
» <a href="{url_logout}">{lang_logout}</a><br>
insert below:
» <a href="contact.php">{lang_contact}</a><br>
5.) search in templates/yourTemplates'/user_loginform.html:
» <a href="{url_register}">{lang_register}</a><br>
insert below:
» <a href="contact.php">{lang_contact}</a><br>
6.) create a new file called "contact.html" and store in you templates folder:
{header}
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablehead">
<tr>
<td width="100%" colspan="4"><table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="6"><img src="{template_url}/images/header_top_left.gif" width="6" height="6" alt="header_top_left" ></td>
<td width="100%"><img src="{template_url}/images/header_top.gif" width="100%" height="6" alt="header_top" ></td>
<td width="6"><img src="{template_url}/images/header_top_right.gif" width="6" height="6" alt="header_top_right" ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="6"><img src="{template_url}/images/header_left.gif" width="6" height="60" alt="header_left" ></td>
<td width="100%"><img src="{template_url}/images/header_logo.gif" width="405" height="60" alt="header_logo.gif" ></td>
<td width="225" align="right">
<form method="post" action="{url_search}">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<input type="text" name="search_keywords" size="15" class="searchinput" >
</td>
<td>
<input type="submit" value="{lang_search}" class="button" name="submit" >
</td>
</tr>
<tr valign="top">
<td colspan="2"><a href="{url_search}" class="smalltext">{lang_advanced_search}</a></td>
</tr>
</table>
</form>
</td>
<td align="right" width="6"><img src="{template_url}/images/header_right.gif" width="6" height="60" alt="header_right" ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="bordercolor">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="tablebgcolor">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="navbar" height="23">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<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>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" valign="top" class="row2">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head2" height="20"><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"> <img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" >{lang_random_image}</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">
<br>
{random_image}
<br>
<br>
</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{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="100%" valign="top"><br >
<b class="title">{lang_contact}</b>
<hr size="1" >
{if msg}<b>{msg}</b><br><br>{endif msg}
{content}
<p> </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>
<p> </p> -->
</td>
<td width="20" valign="top"><img src="{template_url}/images/spacer.gif" width="19" height="19" alt="" ></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablebottom">
<tr>
<td width="6" nowrap><img src="{template_url}/images/footer_left.gif" width="6" height="19" alt="" ></td>
<td width="100%"></td>
<td width="6" nowrap><img src="{template_url}/images/footer_right.gif" width="6" height="19" alt="" ></td>
</tr>
</table>
</td>
</tr>
</table>
{footer}
7.) create a new file called "contact_mailform.html" and store in you templates folder:
<table width="100%" class="row2" border="0" cellpadding="4" cellspacing="0">
<form name="contact_mailform" action="{url_contact}" method="POST" >
<tr>
<td align="right"> </td>
<td align="left" valign="top" >
<br>
<b>{lang_mail_custom_text}
<p> </p>
</b>
</td>
</tr>
{select}
<tr>
<td align="right" valign="middle"><b>{lang_your_name}</b></td>
<td align="left"><input class="input" name="sender_name" type="text" tabindex="1" value="{sender_name}" >
</td>
</tr>
<tr>
<td align="right" valign="middle"><b>{lang_your_mail}</b></td>
<td align="left"><input class="input" name="sender_email" type="text" tabindex="2" value="{sender_email}" >
</td>
</tr>
<tr>
<td align="right" valign="middle"><b>{lang_subject}</b></td>
<td align="left"><input class="input" name="subject" type="text" tabindex="3" value="{subject}" ></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" tabindex="4">{message}</textarea> </td>
</tr>
{if captcha_contact}
<tr>
<td align="right" valign="top"><b>{lang_captcha}</b></td>
<td align="left" valign="top">
<a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" border="0" id="captcha_image" ></a><br>
</td>
</tr>
<tr>
<td align="right" valign="middle"> </td>
<td align="left" valign="top" size="20">{lang_captcha_desc}</td>
</tr>
<tr>
<td align="right" valign="middle"> </td>
<td align="left" valign="top"><input class="input" type="text" name="captcha" id="captcha_input" tabindex="5" ></td>
</tr>
{endif captcha_contact}
<tr>
<td align="right" valign="middle"> </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="postbutton" value="{lang_submit}" class="button" style="margin-right:13px; ">
<input tabindex="6" type="reset" name="reset" value="{lang_reset}" class="button">
<br>
<br>
<br>
</td>
</tr>
<script type="text/javascript">
// set focus to form field
Form = document.getElementById("contact_mailform");
Form.sender_name.focus();
</script>
</form>
</table>
8.) search in global.php:
$captcha_enable_comments = 1;
insert above:
$captcha_enable_contact = 1;
search:
if (!$captcha_enable) {
insert below:
$captcha_enable_contact = 0;
9.) Optional: send e-mail to images owner
search in details.php:
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
redirect($url);
}insert below:
if(($image_row['user_showemail'] == 1) && ($user_info['user_level'] != GUEST)){
$send_detail = "<a href=\"contact.php?user_id=".$image_row['user_id']."\"><img src=\"".get_gallery_image("email.gif")."\" border=\"0\" alt=\"\" /></a>";
$site_template->register_vars("send_detail",$send_detail);
}
search:
get_user_table_field(", u.", "user_email")."and replace:
get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail")."9.1) search in the code "contact.php":
if ($user_info['user_level'] != GUEST) {
$select = "<tr>";
$select .= "<td align=\"right\" valign=\"middle\"><b>".$lang['mail_to']."</b></td>";
$sql = "SELECT user_id,user_level,user_name,user_email,user_allowemails
FROM ".USERS_TABLE."
WHERE user_level = 9 AND user_allowemails = 1
ORDER BY user_name ASC ";
$result = $site_db->query($sql);
$select .= "<td align=\"left\"><select class=\"input\" name=\"emails\" >\n";
$select .= "<option value=\"".$config['site_email']."\" class=\"dropdownmarker\">".$lang['userlevel_admin']."</option>\n";
and replace:
if ($user_info['user_level'] != GUEST) {
$user_id = ($HTTP_GET_VARS['user_id'] > 0) ? intval($HTTP_GET_VARS['user_id']) : 0;
$user_id_sql =($user_id > 0)? "user_id = $user_id" : "user_level = 9";
$select = "<tr>";
$select .= "<td align=\"right\" valign=\"middle\"><b>".$lang['mail_to']."</b></td>";
$sql = "SELECT user_id,user_level,user_name,user_email,user_allowemails
FROM ".USERS_TABLE."
WHERE $user_id_sql AND user_allowemails = 1
ORDER BY user_name ASC ";
$result = $site_db->query($sql);
$select .= "<td align=\"left\"><select class=\"input\" name=\"emails\" >\n";
if($user_id == 0 ){
$select .= "<option value=\"".$config['site_email']."\" class=\"dropdownmarker\">".$lang['userlevel_admin']."</option>\n";
}
9.2) in your template/details.html search:
{lightbox_button}
insert before:
{send_detail}
10.) Optional: Chaptcha can mathematics
search in includes/captcha_utils.php:
function captcha_get_code() {
global $captcha_path, $captcha_chars, $captcha_wordfile, $captcha_length;
replace:
//###################### chaptcha mathematics start #######################
function calculation(){
global $site_sess;
$math = range(0,9);
shuffle($math);
$code = "$math[0]+$math[1]+$math[2]";
$sum = $math[0]+$math[1]+$math[2];
$site_sess->set_session_var('result', $sum);
return $code;
}
function captcha_validate_sum($result) {
global $site_sess, $captcha_enable, $user_info;
if (!$captcha_enable || $user_info['user_level'] == ADMIN) {
return true;
}
$sess_sum = trim($site_sess->get_session_var('result'));
$valid_result = $sess_sum != '' && $sess_sum == $result;
$site_sess->drop_session_var('result');
return $valid_result;
}
//###################### chaptcha mathematics end #########################
function captcha_get_code() {
global $captcha_path, $captcha_chars, $captcha_wordfile, $captcha_length,$captcha_calculation;
//###################### chaptcha mathematics start #######################
if($captcha_calculation){
return calculation();
}
//###################### chaptcha mathematics end #########################
10.1) search in root/global.php:
$captcha_ttf = 1;insert below:
$captcha_calculation = 1;10.2 search in contact.php:
$captcha = (isset($_POST['captcha'])) ? un_htmlspecialchars(trim($_POST['captcha'])) : "";insert below:
$result = (isset($_POST['result'])) ? intval(trim($_POST['result'])):"";
search:
if ($captcha_enable_contact && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
insert below:
if ($captcha_enable_contact && $captcha_calculation && !captcha_validate_sum($result)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_result'];
$error = 1;
}
search:
"lang_captcha_desc" => $lang['captcha_desc'],and replace:
//###################### chaptcha mathematics start #######################
"captcha_calculation" => (bool)$captcha_calculation,
"lang_captcha_desc" => ($captcha_calculation) ? $lang['captcha_desc_result'] : $lang['captcha_desc'],
//###################### chaptcha mathematics end #########################
10.3 search in your Template/style.css:
.input{
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
width: 230px;
}
insert below:
.input_res{
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
width: 30px;
}
10.4 search in lang/deutsch/main.php:
$lang['captcha_required'] = 'Das Feld mit dem Bestätigungs-Code muss ausgefüllt werden.';
insert below:
$lang['captcha_result'] = "Ihr Ergebnis stimmt nicht, bitte versuchen Sie es noch einmal !";
$lang['captcha_desc_result'] = "Bitte tragen Sie die Rechnung aus dem Bild in das Textfeld darunter ein, und schreiben das Ergebnis rechts davon hinein.<br>Wenn Sie Probleme haben den Code zu erkennen, klicken Sie auf das Bild um ein neues zu erhalten.";
10.4.1 search in lang/english/main.php:
$lang['captcha_required'] = 'Please enter the verification code.';insert below:
$lang['captcha_result'] = "Your result is wrong, please try again !";
$lang['captcha_desc_result'] = "Please enter the code from the image into the text field below, and write the result right inside of it.<br>If you have problems identifying the image, click on it to get a new one..";
10.5 search in your templatet/contact_mailform.html:
<td align="left" valign="top"><input class="input" type="text" name="captcha" id="captcha_input" tabindex="5"></td>
and replace:
<td align="left" valign="top"><input class="input" id="captcha_input" type="text" name="captcha" tabindex="5">{if captcha_calculation} = <input class="input_res" name="result" type="text" >{endif captcha_calculation}</td>
mfg Andi