// For new versions visit: // https://jveweb.net/en/archives/2011/07/.html // This is a simple contact form that sends an e-mail // It uses a captcha to prevent robots from filling it and // spamming your e-mail address // It also uses regular expressions to filter the name and e-mail // And it passes the message through one or multiple blacklists of words require_once('recaptchalib.php'); // This are the relevant variables to get the script working // This two variables are the keys given when you register a site at recaptcha.net $publickey = "6LfCWsYSAAAAAF04PIqesmtojFGrmxhMt_2iA33y"; $privatekey = "6LfCWsYSAAAAANcViITiTPqSeP1etRMSAwKPs4LT"; // The address where we send the e-mail to $to = 'contact@jveweb.net'; // The subject of the e-mail $subject = 'A message from your contact form'; // The from e-mail, this may be a noreply@something $from = 'noreply@jveweb.net'; // If this is true, the e-mail given by the person is used in the Reply-To // header of the e-mail, allowing us to click reply in our e-mail client. // Change it to true if you want this to happen. The e-mail address is // included in the body of the e-mail in either case $reply_to_sender = True; // Finally, an array of blacklist files. I am only using one blacklist with // all the words mixed, but I can see the use for having separate ones // such as one for spam, one for English swearing, one for Spanish, etc. // I'll probably compile such lists, so check back the article for updates $blacklists = array( // "spam.txt", // "english.txt", // "spanish.txt", "98733487.txt"); // Before process the contents of the message, validate the captcha if (isset($_POST["recaptcha_challenge_field"]) && isset($_POST["recaptcha_response_field"])) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // If the CAPTCHA is incorrect, show an error message $result_message = "The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"; } else { // If the captcha is correct, verify that all fields were filled if ($_POST["name"]!="" && $_POST["email"]!="" && $_POST["content"]!="") { // Strip the html tags, we don't want them $tmp_name = substr($_POST["name"],0,100); $tmp_email = substr($_POST["email"],0,100); $tmp_content = substr($_POST["content"],10000); // Check the validity of the name with a regular expression if (!preg_match('/^[a-zA-ZÀ-ÖØ-öø-ÿ]+\.?((( |\-)[a-zA-ZÀ-ÖØ-öø-ÿ]+\.?)|([A-Z]\.?))*$/',$tmp_name)) { $result_message = "The name is invalid "; } // Check the validity of the e-mail with a regular expression // This particular regular expression probably needs to be updated // thanks to ICANN and all the new possible tlds, but it should // be working fine at this point in time // Check the article for updates if (!preg_match("/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)$/", $tmp_email)) { $result_message = "The e-mail address is invalid"; } // Match the original message against a list of unwanted words // Only the content of the message is filtered using the blacklists // After we passed the original content through the blacklist(s), if the // resulting message differs from the original one, then words from the // blacklist(s) were found in the message and therefore we don't send it // But first, turn the content to lowercase and change some the special // characters in Spanish for a better filtering of words $reference = strtolower($tmp_content); $special_characters = array('/á/','/é/','/í/','/ó/','/ú/','/ü/','/Á/','/É/','/Í/','/Ó/','/Ú/'); $simple_characters = array('a','e','i','o','u','u','A','E','I','O','U'); $reference = preg_replace($special_characters,$simple_characters,$reference); // Now, copy the reference and pass it through the filters $filtered_content = $reference; foreach ($blacklists as $file) { $blacklist = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $blacklist = preg_replace('/(.*)/','/$1',$blacklist); $filtered_content = preg_replace($blacklist,'',$filtered_content); } // Check if words were found in the blacklist if ($reference != $filtered_content) { $result_message = "The message was not accepted, something is in the blacklist of words"; } // If anything went wrong, the variable $result_message will be set at this point // If it is not, then send the e-mail, otherwise just ignore this part if (!isset($result_message)) { // Define the headers we want. Note that they are separated with \r\n $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=utf-8\r\n"; $headers .= "From: $from\r\n"; if ($reply_to_sender) { $headers .= "Reply-To: $tmp_email"; } else { $headers .= "Reply-To: $from"; } // Create the message $body = << Contact - Juan Valencia's website

Contact

There is the usual way, an e-mail to contact at jveweb dot net (I will post my PGP key in the near future, just in case).

I am also trying Google+ nowadays, Here is my Profile.

And of course, here is a contact form. It allows a maximum of 10000 characters. If your message involves more than that you can send me an e-mail.

Contact form

Comments/Bugs/Corrections/Criticism/A story

About Juan Valencia Escalante

A programmer mostly interested in free software, free culture, privacy and ending the hunger in the world.

My areas of expertise are:

PHP, HTML (XHTML, HTML 5), CSS, Javascript, C/C++, Python, MySQL, PostgreeSQL, Command line scripting, ViM scripting, Linux administration, free software licences.

My areas of interest include (I am not as experienced, yet):

Java, LaTeX, Lisp, The Gimp, Inkscape, physics, drawing, macrophotography, guitar.

Skills that are either obsolete or that I lost interest in, but that I could still perform:

Visual Basic, ActionScript

Some other facts about me:

  • I am a Dvorak user (a keyboard layout alternative to qwerty).
  • I am a ViM user
  • I use KDE and Fluxbox
  • I have either Slackware or Kubuntu on my computers.
  • I install Linux for free to anyone whom may want to try it (although I accept donations and this is conditioned to me having free time).
  • I have compiled kernels, set up systems with full disk encryption (netbooks, with slackware), configure a laptop as a multiseat system, made SlackBuilds, backup full HDDs over network cables, remotely set up a virtual hosting, installed systems using NFS as source, and made circuitry and software to control physical things with the computer, of course I have programmed systems, and many other things.

My multi-seat setup, don't try this with recent versions of Ubuntu, evidently it is possible, but due to some changes that they have been implementing it is more complicated.
Two images joined showing a multi-seat setup, the left side shows the front and the right side shows the back.

This is not the definitive layout that I want for my website, but at the time of start it was either make my own layout or start publishing content, and time is in short supply. (I was using a different publishing system as well, but that was sorted out).