deformed-offering

Weather station scripts

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Saturday, 07-Apr-2018 2:40 PM

Contact Page with Google reCAPTCHA V2.0

Having a 'safe' way to contact you on your website is a good idea. In 2008, Mike Challis of 642weather.com released a contact page for both standalone and Saratoga templates that used a built-in PHP script to create a captcha that minimized the ability of spambots to post messages. The bad news is that the spambots have caught on to the algorithm/structure of that captcha and so now can freely post spam using the old form/captcha that was released.

This script retools Mike's original form to use the Google reCAPTCHA V2.0 which is very much more resistant to spambot postings. The script comes as a standalone contact.php/contact-inc.php which is English only. The Saratoga template wxcontact.php/contact-inc.php/wxcontact-LL.html offers multilingual use in the template for all supported languages.

Screen captures of standalone and Saratoga template use

Standalone Saratoga Template
Standalone Contact Form Template Contact form

Get a reCAPTCHA Key pair and configure the script

This script requires a reCAPTCHA SITE and SECRET key pair to operate the Google reCAPTCHA.

  1. Go to https://www.google.com/recaptcha/admin and sign in to the site.
  2. Click on 'Register a new site' and fill in the following:
    1. The Label field with a short name for your key pair
    2. Select "reCAPTCHA V2" for the reCAPTCHA type
    3. Fill in the website domain names (mywebsite.com, mywebsite.net, etc) in the Domains box for all the websites you will use the script.
    4. Check the "Accept terms and conditions" checkbox
    5. Leave the "Send alerts to owners" checkbox checked so you can be alerted to problems.
    6. Press "Register" button
  3. When the page displays with "Adding reCAPTCHA to your sites", click on "Keys" to display the keys.
  4. Copy the contents of the "Site Key" to $recaptchaSiteKey variable in contact-inc.php settings area.
  5. Copy the contents of the "Secret Key" to $recaptchaSecretKey variable in contact-inc.php settings area.
  6. Complete setup by configuring $logFile, $mailto and $sitename variables as discussed below.
  7. Upload your configured contact-inc.php and test it.

Settings

Configure contact-inc.php with the settings for your website.


############################################################################
# begin settings
############################################################################
# always configure these options before use
# always test your contact form after making changes
#
# This script REQUIRES a google reCAPTCHA key pair.  Use
# https://www.google.com/recaptcha/admin to acquire a key pair
#  insert your Site Key and Site Secret Key in the two variables below

 
$recaptchaSiteKey =   '-google-site-key-';   // your reCAPTCHA site key
 
$recaptchaSecretKey '-google-secret-key-';   // your reCAPTCHA site secret key

# Optional log file.  use '' as the name if a log file is not desired.
 
$logFile './cache/contact-log.txt'// optional text log of messages.  use '' to disable.

 # email address to receive messages from this form
 
$mailto 'somebody@somesite.com';

 
# Site Name / Title
 
$sitename 'My Sitename';

############################################################################
# end settings
############################################################################ 
?>
$recaptchaSiteKey
This variable specifies your Google reCAPTCHA SITE KEY. Copy from the reCAPTCHA admin webpage.
$recaptchaSecretKey
This variable specifies your Google reCAPTCHA SECRET KEY. Copy from the reCAPTCHA admin webpage.
$logFile
This variable controls the optional text logfile of messages sent by the script. The default is './cache/contact-log.txt'.
$logFile = ''; will disable creation of a log file.
$mailto
This is the full email address to receive the messages sent via the script
$sitename
This is a short name for your website. Email messages will arrive to $mailto address with a Subject line of:
""$sitename contact: $subject" (where $subject is from the submitted message form).

Saratoga template multilingual configuration

There are two areas to configure for multilingual configuration. The language-LL.txt and wxcontact-LL.html files are the two files to configure for each LL language on your site.

The following entries should be made to language-LL.txt:

Right-click in the above textbox, Select ALL, right-click, Copy then paste to the end of language-LL.txt and change the third field (delimited by | ) with the language translation. Make sure the translation is done using the ISO-8859-n character set appropriate to your translation, and not UTF-8. Save and upload to your website.

Copy wxcontact-en.html to wxcontact-LL.html to make a new boilerplate file for language LL. In the new file, the parts to edit are below the $main_top_text, $welcome_intro and $thank_you variables. You can use a mix of text, HTML and PHP if you like.
If you need to use literal dollar signs ( $ ), escape them by using ( \$ ), otherwise you'll have a PHP error.
Make sure the translation is done using the ISO-8859-n character set appropriate to your translation, and not UTF-8.
Also be careful to not disturb the end markers for each section.
Translate the text as desired for each section, save and upload to your site.
Note: If wxcontact-LL.html is not available on your site for language LL, then the wxcontact-en.html will be used, and if it is missing, the text in the gen_boilerplate() function in contact-inc.php will be used.

Downloads

reCAPTCHA Contact Form [V2.00 - 07-Apr-2018] :
Download for Saratoga Template
Download for Standalone use

Version history

  • Version 2.00 - 07-Apr-2018 rewritten to use Google reCaptcha V2.0
  • Version 1.04 - 07-Jun-2008 added setting for captch library [path]/[folder]
  • Version 1.03 - 07-Jun-2008 added config setting for printing $thank_you message after form is sent
  • Version 1.02 - 30-May-2008 added Lat/Lon fields, fixed "TRIM here" comment syntax
  • Version 1.01 - 29-May-2008 fixed session_start warning "headers already sent"
  • Version 1.00 - 28-May-2008 PHP script originally by Mike Challis, www.642weather.com/weather

 

deformed-offering