blankuvodinfoukážkylinkkontaktblank

Kontaktný formulár

'Joe Somebody', 'EMAIL' => 'joesomebody@yourwebsite.com'), array('CONTACT' => 'Webmaster', 'EMAIL' => 'admin@kiga.sk'), ); // <-- this must remain after your contact array // Normally this setting will be left blank, like this: $email_on_this_domain = ''; // Some Web hosts do not allow your PHP to send email unless the From: email address // is from the same domain. If your form does not seem to be sending any email, then // set this to your email address on the SAME domain as your web site as a possible workaround $email_on_this_domain = ''; // Name of this file // If you rename this file, you must change this or the form will not work $file_name = 'contact.php'; // Site Name / Title $sitename = 'Svet tickerov'; // Site Domain without the http://www like this: $domain = '642weather.com'; // Can be a single domain: $domain = '642weather.com'; // Can be an array of domains: $domain = array('642weather.com','someothersite.com'); $domain = 'ticker.kiga.sk'; // Make sure the form was posted from your host name only. // SET $domain_protect =1; for ON, $domain_protect = 0; for OFF. // This is a security feature to prevent spammers from posting from files hosted on other domain names // "Input Forbidden" message will result if host does not match $domain_protect = 1; // Double E-mail entry is optional // enabling this requires user to enter their email two times on the contact form. // SET $enable_double_email = 1; ON, $enable_double_email = 0; for OFF. $enable_double_email = 0; // CAPTCHA is optional but recommended to prevent spam bots from spamming your contact form // SET $enable_captcha = 1; ON, $enable_captcha = 0; for OFF. $enable_captcha = 1; // CAPTCH library [path]/[folder] (do not end with slash!) // Suggestes use: You can have one captcha-secureimage library in the root of your Web site // sharing many contact forms in other folders as long as you correctly set the relative [path] for each contact form $captcha_library = './captcha-secureimage'; // You can ban known IP addresses // SET $enable_ip_bans = 1; ON, $enable_ip_bans = 0; for OFF. $enable_ip_bans = 0; // Add IP addresses to ban here: (be sure to SET $enable_ip_bans = 1; to use this feature $banned_ips = array( '22.22.22.22', // example (add, change, or remove as needed) '33.33.33.33', // example (add, change, or remove as needed) ); // Wordwrap E-Mail message text so lines are no longer than 70 characters. // SET $wrap_message = 1; ON, $wrap_message = 0; for OFF. $wrap_message = 1; // Content-language for email message header $ctf_language = 'en-us'; // Charset for email message header $ctf_charset = 'UTF-8'; // Content-transfer-encoding for email message header $ctf_encoding = 'quoted-printable'; // OPTIONAL: You can change the default SMTP settings below... // NOTE most servers do not need these settings changed!!! $ctf_ini_set = "no"; // "yes" to enable this feature (ONLY if needed) $ctf_smtp = "localhost"; // sometimes mail.yourdomain.com Confirm with your host $ctf_smtp_port = "25"; // Confirm with your host $ctf_smtp_username = "you"; // your mail username. If you do not know, ask your host $ctf_smtp_password = "123456"; // your mail password. If you do not know, ask your host $ctf_sendmail_from = "you@yourdomain.com"; // Your email $ctf_sendmail_path = "/usr/sbin/sendmail -t -i"; // If different, ask host // Redirect to Home Page after message is sent // SET $ctf_redirect_enable = 1; ON, $ctf_redirect_enable = 0; for OFF. $ctf_redirect_enable = 0; // Used for the delay timer once the message has been sent $ctf_redirect_timeout = 5; // time in seconds to wait before loading another Web page // Web page to send the user to after the time has expired $ctf_redirect_url = 'index.php'; // The $welcome_intro is what gets printed when the form is first presented. // It is not printed when there is an input error and not printed after the form is completed $welcome_intro = << Prosím zadajte správny e-mail,aby sme Vám mohli odpovedať v prípade,ak požadujete odpoveď.

EOT; // do not remove the above EOT line // The $thank_you is what gets printed after the form is sent. $thank_you = <<Správa odoslaná

Vaša správa bola úspešne odoslaná.Ďakujeme!

EOT; // do not remove the above EOT line ################# // end settings ################# ##### ##### # Do not alter any code below this point in the script or it may not run properly. ##### ##### if ($ctf_redirect_enable) { $thank_you .= << Returning to Home Page   Returning to Home Page... EOT; // do not remove the above EOT line } // Test for some required things, print error message if not OK. $requires = 'ok'; if(!function_exists('mail')) { echo '

ERROR: The PHP mail() function is not enabled in PHP!

'; echo '

Contact your web host and ask them why the mail() function is not enabled for PHP.

'; $requires = 'fail'; } if ($enable_captcha) { if ( !extension_loaded("gd") ) { echo '

ERROR: GD image support not detected in PHP!

'; echo '

Contact your web host and ask them why GD image support is not enabled for PHP.

'; $requires = 'fail'; } if ( !function_exists("imagepng") ) { echo '

ERROR: imagepng function not detected in PHP!

'; echo '

Contact your web host and ask them why the imagepng function is not enabled for PHP.

'; $requires = 'fail'; } if ( !file_exists("$captcha_library/securimage.php") ) { echo '

ERROR: captcha_library not found

'; echo '

Did you install the required captcha_library?
Required library:
http://www.642weather.com/weather/scripts/captcha-secureimage.zip
Check that it is installed and the setting $captcha_library file path is set properly inside this script.

'; $requires = 'fail'; } } if ($requires == 'fail') { exit; } // add numbered keys starting with 1 to the $contacts array $cont = array(); $ct = 1; foreach ($contacts as $v) { $cont["$ct"] = $v; $ct++; } $contacts = $cont; unset($cont); // initialize vars $error = 0; $error_print = ''; $message_sent = 0; $mail_to = ''; $to_contact = ''; $name = ''; $email = ''; $email2 = ''; $subject = ''; $text = ''; $code = ''; // add another field here like above $error_captcha = ''; $error_contact = ''; $error_name = ''; $error_email = ''; $error_email2 = ''; $error_subject = ''; $error_text = ''; // add another field here like above // process form now if (isset($_POST['action']) && ($_POST['action'] == 'send')) { // check all input variables $cid = ctf_clean_input($_POST['CID']); if(empty($cid)) { $error = 1; $error_contact = 'Selecting a contact is required.'; } else if (!isset($contacts[$cid]['CONTACT'])) { $error = 1; $error_contact = 'Requested Contact not found.'; } $mail_to = ctf_clean_input($contacts[$cid]['EMAIL']); $to_contact = ctf_clean_input($contacts[$cid]['CONTACT']); $name = ctf_name_case(ctf_clean_input($_POST['name'])); $email = strtolower(ctf_clean_input($_POST['email'])); if ($enable_double_email) { $email2 = strtolower(ctf_clean_input($_POST['email2'])); } $subject = ctf_name_case(ctf_clean_input($_POST['subject'])); $text = ctf_clean_input($_POST['text']); $code = ctf_clean_input($_POST['code']); // add another field here like above // check posted input for email injection attempts // fights common spammer tactics // look for newline injections ctf_forbidifnewlines($name); ctf_forbidifnewlines($email); if ($enable_double_email) { ctf_forbidifnewlines($email2); } ctf_forbidifnewlines($subject); // look for lots of other injections $forbidden = 0; $forbidden = ctf_spamcheckpost(); if ($forbidden) { echo "

Input Forbidden

"; exit; } // check for banned ip if( $enable_ip_bans && in_array($_SERVER['REMOTE_ADDR'], $banned_ips) ) { echo "

Your IP is Banned

"; exit; } // CAPS Decapitator if (!preg_match("/[a-z]/", $text)) { $text = ctf_name_case($text); } if(empty($name)) { $error = 1; $error_name = 'Zadajte vaše meno.'; } if (!ctf_validate_email($email)) { $error = 1; $error_email = 'Je potrebné zadať správny email.'; } if ($enable_double_email && !ctf_validate_email($email2)) { $error = 1; $error_email2 = 'Je potrebné zadať správny email.'; } if ($enable_double_email && ($email != $email2) ) { $error = 1; $error_double_email = 'Zadajte email znovu.'; } if(empty($subject)) { $error = 1; $error_subject = 'Zadajte predmet.'; } if(empty($text)) { $error = 1; $error_text = 'Zadajte text správy.'; } // add another field here like 4 lines above (only if you want it to be required) // begin captcha check if enabled // captcha is optional but recommended to prevent spam bots from spamming your contact form if ($enable_captcha) { if(empty($code)) { $error = 1; $error_captcha = 'Zadajte overovací kód.'; } else { include "$captcha_library/securimage.php"; $img = new Securimage(); $valid = $img->check("$code"); // Check, that the right CAPTCHA password has been entered, display an error message otherwise. if($valid == true) { // ok can continue } else { $error = 1; $error_captcha = 'Zadali ste zlý overovací kód.
Prosím skúste to znova'; } } } // end if enable captcha // end captcha check if (!$error) { // ok to send the email, so prepare the email message // lines separated by \n on Unix and \r\n on Windows if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n"); $subj = "$sitename contact: $subject"; $msg = "Poslané z kontaktného formulára stránky $sitename Komu: $to_contact Od: $name $email Správa: $text "; // add another field here (in the $msg code above) // add some info about sender to the email message $userdomain = ''; $userdomain = gethostbyaddr($_SERVER['REMOTE_ADDR']); $user_info_string = "Poslané z IP (ip address): ".$_SERVER['REMOTE_ADDR']." ($userdomain)" . PHP_EOL; $user_info_string .= "Zo stránky (referer): ".$_SERVER['HTTP_REFERER'] . PHP_EOL; $user_info_string .= "Using (user agent): ".ctf_clean_input($_SERVER['HTTP_USER_AGENT']) . PHP_EOL . PHP_EOL; $msg .= $user_info_string; // wordwrap email message if ($wrap_message) { $msg = wordwrap($msg, 70); } // remove some characters that mess up From: $name <$email> // remove single quote, double quote, semicolon, colon, comma $name = ctf_name_case(preg_replace(array ( '/\'/', '/"/', '/;/', '/:/', '/,/' ), '', $name)); // prepare the email header if ($email_on_this_domain != '') { $header = "Od: $email_on_this_domain" . PHP_EOL; } else { $header = "Od: $name <$email>" . PHP_EOL; } $header .= "Reply-To: $email" . PHP_EOL; $header .= "Return-Path: $email" . PHP_EOL; $header .= 'MIME-Version: 1.0' . PHP_EOL; $header .= 'Content-type: text/plain; Content-language: '.$ctf_language.'; charset="'.$ctf_charset.'"' . PHP_EOL; $header .= 'Content-transfer-encoding: '.$ctf_encoding . PHP_EOL; // send the email if(strtolower($ctf_ini_set) == "yes") { ini_set("SMTP", $ctf_smtp); ini_set("smtp_port", $ctf_smtp_port); ini_set("smtp_password", $ctf_smtp_password); ini_set("smtp_username", $ctf_smtp_username); ini_set("sendmail_from", $ctf_sendmail_from); ini_set("sendmail_path", $ctf_sendmail_path); } ini_set('sendmail_from', $email); // needed for some windows servers mail($mail_to,$subj,$msg,$header); ini_restore('sendmail_from'); // needed for some windows servers $message_sent = 1; } // end if ! error } // end if posted action = send if($message_sent) { // thank you mesage is printed here echo $thank_you; echo "\n
"; }else{ if (!$error) { // welcome intro is printed here unless message is sent echo $welcome_intro; } echo "\n"; echo "\n\n"; echo '
Kontaktný formulár'; // print any input errors if ($error) { $error_print .= '

INPUT ERROR: Please make corrections below and try again.

'."\n"; echo $error_print; } if (count($contacts) > 1) { echo '
'.echo_if_error($error_contact).'
' . "\n"; } else { echo ''."\n"; } echo '
'.echo_if_error($error_name).'

'; if ($enable_double_email) { echo'
'.echo_if_error($error_email).' '.echo_if_error($error_double_email).'
'.echo_if_error($error_email2).'

'; } else { echo'
'.echo_if_error($error_email).'

'; } echo '
'.echo_if_error($error_subject).'
'.echo_if_error($error_text).'

'; # captcha is optional but recommended to prevent spam bots from spamming your contact form if ($enable_captcha) { echo '
'.echo_if_error($error_captcha).'
'; } echo '

Ďakujeme za vašu otázku,alebo komentár!
'; } function echo_if_error($this_error){ global $error; if ($error) { if (!empty($this_error)) { return 'ERROR: ' . $this_error . ''."\n"; } } } // functions for protecting and validating form input vars function ctf_clean_input($string) { if (is_string($string)) { return trim(ctf_sanitize_string(strip_tags(ctf_stripslashes($string)))); } elseif (is_array($string)) { reset($string); while (list($key, $value) = each($string)) { $string[$key] = ctf_clean_input($value); } return $string; } else { return $string; } } function ctf_sanitize_string($string) { $string = ereg_replace(' +', ' ', trim($string)); return preg_replace("/[<>]/", '_', $string); } function ctf_stripslashes($string) { if (get_magic_quotes_gpc()) { return stripslashes($string); } else { return $string; } } function ctf_output_string($string) { return str_replace('"', '"', $string); } // A function knowing about name case (i.e. caps on McDonald etc) // $name = name_case($name); function ctf_name_case($name) { if ($name == '') return ''; $break = 0; $newname = strtoupper($name[0]); for ($i=1; $i < strlen($name); $i++) { $subed = substr($name, $i, 1); if (((ord($subed) > 64) && (ord($subed) < 123)) || ((ord($subed) > 48) && (ord($subed) < 58))) { $word_check = substr($name, $i - 2, 2); if (!strcasecmp($word_check, 'Mc') || !strcasecmp($word_check, "O'")) { $newname .= strtoupper($subed); }else if ($break){ $newname .= strtoupper($subed); }else{ $newname .= strtolower($subed); } $break = 0; }else{ // not a letter - a boundary $newname .= $subed; $break = 1; } } return $newname; } function ctf_validate_email($email) { // Create the syntactical validation regular expression $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; // Presume that the email is invalid $valid = 0; //check for all the non-printable codes in the standard ASCII set, //including null bytes and newlines, and exit immediately if any are found. if (preg_match("/[\\000-\\037]/",$email)) { return 0; } // Validate the syntax if (eregi($regexp, $email)) { list($username,$domaintld) = split("@",$email); // Validate the domain if ( function_exists("getmxrr") ) { if (getmxrr($domaintld,$mxrecords) ) { $valid = 1; } } else { $valid = 1; } } else { $valid = 0; } return $valid; } function ctf_forbidifnewlines($input) { if (eregi("\r", $input) || eregi("\n", $input) || eregi("%0a", $input) || eregi("%0d", $input)) { echo "

Input Forbidden

"; exit; } } function ctf_spamcheckpost() { global $domain, $domain_protect; if(!isset($_SERVER['HTTP_USER_AGENT'])){ return 1; } // Make sure the form was indeed POST'ed: // (requires your html form to use: action="post") if(!$_SERVER['REQUEST_METHOD'] == "POST"){ return 2; } // Make sure the form was posted from an approved host name. if ($domain_protect) { // Host names from where the form is authorized to be posted from: if (is_array($domain)) { $domain = array_map(strtolower, $domain); $authHosts = $domain; } else { $domain = strtolower($domain); $authHosts = array("$domain"); } // Where have we been posted from? if( isset($_SERVER['HTTP_REFERER']) and trim($_SERVER['HTTP_REFERER']) != '' ) { $fromArray = parse_url(strtolower($_SERVER['HTTP_REFERER'])); // Test to see if the $fromArray used www to get here. $wwwUsed = strpos($fromArray['host'], "www."); if(!in_array(($wwwUsed === false ? $fromArray['host'] : substr(stristr($fromArray['host'], '.'), 1)), $authHosts)){ return 3; } } } // end if domain protect // check posted input for email injection attempts // Check for these common exploits // if you edit any of these do not break the syntax of the regex $input_expl = "/(content-type|mime-version|content-transfer-encoding|to:|bcc:|cc:|document.cookie|document.write|onmouse|onkey|onclick|onload)/i"; // Loop through each POST'ed value and test if it contains one of the exploits fromn $input_expl: foreach($_POST as $k => $v){ $v = strtolower($v); if( preg_match($input_expl, $v) ){ return 4; } } return 0; } ?>

© 2009 Svet tickerov