Mój problem dotyczy wtyczki o nazwie Simple Modal Contact Form (http://www.ericmmartin.com/projects/simp...l-demos/). Obecnie jest to wtyczka do Wordpressa, lecz wcześniejsza wersja była przystosowania do zainstalowania w normalny sposób (poprzez wklejenie kodu w do odpowiednich plików)
Otóż, pobrałem sobie wcześniejszą wersję tej wtyczki i trochę ją zmodyfikowałem do swoich potrzeb. Można ją obejrzeć pod adresem:
http://allegro.designestore.pl/plugin/co...index.htmlJak widać, na testowej stronie wszystko działa dobrze. Problem pojawił się gdy chciałem zainstalować zmodyfikowaną wtyczkę na sklepie ClickShop (home.pl), a dokładnie tutaj:
http://www.designestore.pl/Jak widać, na tej stronie nic się nie dzieje. Początkowo myślałem, że może to powodować konflikt z jakimś skryptem MooTools lub innym jQuery. Jednak nawet po pozbyciu się w praktycznie wszystkich skryptów JavaScript ze strony nic się nie zmieniło.
Poniżej przedstawiam działanie wtyczki i wklejam kod:
--------------------------------------------------------------
Za działanie wtyczki odpowiada plik JavaScript dostępny tutaj:
http://allegro.designestore.pl/plugin/co...contact.js (dodam, że w ClickShopie nie ma bezpośredniego dotępu do plików sklepu, więc w taki sposób odnoszę się do plików .js i .php ze skryptu)
Po kliknięciu w zakładkę "Twoja Sugestia" uruchamia on oknom, do którego wczytuje zawartość pliku PHP (w tym pliku znajduje się właśnie wyświetlany formularz). A oto kod:
<?php
// User settings
$to = "tomaszkikowski@gmail.com";
$subject = "SimpleModal Contact Form";
// Include extra form fields and/or submitter data?
// false = do not include
"form_subject" => true,
"form_cc" => true,
"ip" => true,
"user_agent" => true
);
// Process
$action = isset($_POST["action"]) ?
$_POST["action"] : ""; // Send back the contact form HTML
$output = "<div style='display:none'>
<div class='contact-top'></div>
<div class='contact-content'>
<h1 class='contact-title'>Twoja sugestia</h1>
<div class='contact-loading' style='display:none'></div>
<div class='contact-message' style='display:none'></div>
<form action='#' style='display:none'>
<p class='p-contact'>Czekamy na Twoje sugestie na temat działania sklepu Design eStore.</p>
<label for='contact-name'>*Nadawca:</label>
<input type='text' id='contact-name' class='contact-input' name='name' tabindex='1001' />
<label for='contact-email'>*E-mail:</label>
<input type='text' id='contact-email' class='contact-input' name='email' tabindex='1002' />";
if ($extra["form_subject"]) {
$output .= "
<label for='contact-subject'>Temat:</label>
<select name='subject' id='contact-subject' class='contact-input' tabindex='1003'>
<option value=''>wybierz...</option>
<option value='Design eStore::MamPytanie'>Mam pytanie do Design eStore</option>
<option value='Design eStore::MamPomysl'>Mam pomysł na zmiane</option>
<option value='Design eStore::PropozycjaWspolpracy'>Mam propozycję współpracy</option>
<option value='Design eStore::UwagaTechniczna'>Mam uwagę techniczną</option>
<option value='Design eStore::Inne'>Inne</option>
</select>";
}
$output .= "
<label for='contact-message'>*Treść:</label>
<textarea id='contact-message' class='contact-input' name='message' cols='40' rows='4' tabindex='1004'></textarea>
<br/>";
if ($extra["form_cc"]) {
$output .= "
";
}
$output .= "
<label> </label>
<button type='submit' class='contact-send contact-button' tabindex='1006'>Wyślij</button>
<br/>
<input type='hidden' name='token' value='" . smcf_token($to) . "'/>
</form>
</div>
<div class='contact-bottom'></div>
</div>";
}
else if ($action == "send") {
// Send the email
$name = isset($_POST["name"]) ?
$_POST["name"] : ""; $email = isset($_POST["email"]) ?
$_POST["email"] : ""; $subject = isset($_POST["subject"]) ?
$_POST["subject"] : $subject; $message = isset($_POST["message"]) ?
$_POST["message"] : ""; $cc = isset($_POST["cc"]) ?
$_POST["cc"] : ""; $token = isset($_POST["token"]) ?
$_POST["token"] : "";
// make sure the token matches
if ($token === smcf_token($to)) {
smcf_send($name, $email, $subject, $message, $cc);
echo "<p style='color: #333; margin: 15px 0 0 0;'> Twoja wiadomość została wysłana. </p></br>
<button class='contact-button' tabindex='1007' onClick='$.modal.close();'>Zamknij</button>
";
}
else {
echo "Niestety, Twoja wiadomość nie może zostać zweryfikowana"; }
}
function smcf_token($s) {
return md5("smcf-" . $s . date("WY")); }
// Validate and send email
function smcf_send($name, $email, $subject, $message, $cc) {
// Filter and validate fields
$name = smcf_filter($name);
$subject = smcf_filter($subject);
$email = smcf_filter($email);
if (!smcf_validate_email($email)) {
$subject .= " - błędny e-mail";
$message .= "\n\nZły e-mail: $email";
$email = $to;
$cc = 0; // do not CC "sender"
}
// Add additional info to the message
if ($extra["ip"]) {
$message .= "\n\nAdres IP: " . $_SERVER["REMOTE_ADDR"];
}
// Set and wordwrap message body
$body = "Nadawca: $name, $email\n\n";
$body .= "Treść wiadomości: \n\n$message";
// Build header
$headers = "Nadawca: $email\n";
if ($cc == 1) {
$headers .= "Wysłano również pod adres: $email\n";
}
$headers .= "X-Mailer: PHP/SimpleModalContactForm";
// UTF-8
if (function_exists('mb_encode_mimeheader')) {
$subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
}
else {
// you need to enable mb_encode_mimeheader or risk
// getting emails that are not UTF-8 encoded
}
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\n";
// Send email
@mail($to, $subject, $body, $headers) or
die("Niestety, wystąpił problem z serwerem. Twoja wiadomość nie została wysłana."); }
// Remove any un-safe values to prevent email injection
function smcf_filter($value) {
$pattern = array("/\n/","/\r/","/content-type:/i","/to:/i", "/from:/i", "/cc:/i"); return $value;
}
// Validate email address format in case client-side validation "fails"
function smcf_validate_email($email) {
// Make sure the at (@) sybmol exists and
// it is not the first or last character
if ($at && ($at < 1
|| ($at + 1
) == strlen($email))) return false;
// Make sure there aren't multiple periods together
return false;
// Break up the local and domain portions
$local = substr($email, 0
, $at); $domain = substr($email, $at + 1
);
// Check lengths
if ($locLen < 1 || $locLen > 64 || $domLen < 4 || $domLen > 255)
return false;
// Make sure local and domain don't start with or end with a period
return false;
// Check for quoted-string addresses
// Since almost anything is allowed in a quoted-string address,
// we're just going to let them go through
// It's a dot-string address...check for valid characters
if (!preg_match('/^[-a-zA-Z0-9!#$%*\/?|^{}`~&\'+=_\.]*$/', $local)) return false;
}
// Make sure domain contains only valid characters and at least one period
return false;
return true;
}
?>
Może ktoś z was pomoże mi znaleźć przyczynę tego błędu, lub wskaże gdzie szukać przyczyny problemem.