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.

Many of these scripts are now available on GitHub at https://github.com/ktrue

Buy Me A Coffee 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.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

This page was updated 14-Apr-2020 10:34 AM

Contact Page with Google reCAPTCHA or hCaptcha

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 or hCaptcha which are very much more resistant to spambot postings. The scripts come as a standalone contact.php/contact-inc.php/contactH-inc.php which are English only. The Saratoga template wxcontact.php/contact-inc.php/contactH-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/hCaptcha SITE and SECRET key pair to operate.
For 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.

For hCaptcha:

  1. Go to https://dashboard.hcaptcha.com/signup and create a login ID and sign in to the site.
  2. Click on New Site' and fill in the following:
    1. The Hostname using the site
    2. The 'Interest Group' (which determines what type of images will be shown in the captcha)
    3. Set the Captcha Difficulty as you wish. I use 'Difficult'.
    4. Click on 'Save' and the dashboard should display.
  3. Click on the 'Settings' for the new key and copy the Site Key to the clipboard.
  4. Copy the contents of the "Site Key" to $recaptchaSiteKey variable in contactH-inc.php settings area.
  5. Click on the 'Settings' tab on the dashboard page to show your Secret Key.
  6. Copy the contents of the "Secret Key" to $recaptchaSecretKey variable in contactH-inc.php settings area.
  7. Complete setup by configuring $logFile, $mailto and $sitename variables as discussed below.
  8. Upload your configured contactH-inc.php.
  9. Change the $useGoogle = true; to $useGoogle = false; in contact.php and wxcontact.php to enable hCaptcha instead of the default Google reCaptcha
  10. Upload your configured contact.php and wxcontact.php.

Settings

Configure contact-inc.php or contactH-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 CAPTCHA SITE KEY. Copy from the CAPTCHA admin webpage.
$recaptchaSecretKey
This variable specifies your CAPTCHA SECRET KEY. Copy from the CAPTCHA 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

CAPTCHA Contact Form [V3.00 - 14-Apr-2020] :
Download for Saratoga Template
Download for Standalone use

Version history

  • Version 3.00 - 14-Apr-2020 added scripts to allow use of hCaptcha instead of Google reCaptcha
  • Version 2.01 - 09-Aug-2018 removed each() for PHP7 compatibility
  • 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