Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Expiry Script

Posted by TedH (TedH), 28 June 2006
You spent a lot of money going on Graham's course, then considerably more time developing a Perl application. Often webmasters have a script or system which they license out on a yearly basis to clients hosted on their web server. After all, you've done a lot work here and would like to see some reward for it, recoup your expenses and pay your mortgage.

I've received a lot from this forum and thought it might be nice to contribute something for a change.

This is a script I've written and use for license expiry on a system I've put together for client usage. It's quite simple. I've tried to see if I could break it and it's stood the course. There may be simpler ways of doing this, but then I'm not that expert at it.

You can incorporate this by a require (name it to something obscure) in your main script. I use an external HTML page for notification (it looks nicer). There's no name to this script - make up your own.

Code:
#!/usr/bin/perl

# Expiry Script
# Ted Hawkins (ted-hawkins.com)
# Free to use as you want.
## ------------------------------ ##
## Change the targets to reflect  ##
## your script where noted below. ##
## Alter dates as needed.         ##
## ------------------------------ ##

# use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print "Content-type: text/html\n\n";
$expurl = "http://ANYURLTO/expiry.html"; # Separate expiry page;

# Alter dates here.
$expirydate = "20100430";  # Expiry date for calculations (MUST be in this format).
$runsouton = "30.04.2010"; # Expiry date for viewing.

print "<html><head><title></title></head><body><basefont face=verdana font size=4>\n";

# time calculations (alter for gmtime or localtime as needed)
&endTheyear; # calls the key sub routine
sub endTheyear {
### date and time
# ($sec,$min,$hour,$mday,$mon,$year) = gmtime;
($sec,$min,$hour,$mday,$mon,$year) = localtime;
$year = $year + 1900;
$mon = $mon + 1;
if ($mon <10) {$mon = "0$mon";}
if ($mday <10) {$mday = "0$mday";}
if ($hour<10) {$hour = "0$hour";}
if ($min<10) {$min = "0$min";}
$nowtime = ($mday.".".$mon.".".$year);  # for current date
$licensetime = ($year.$mon.$mday);      # expiry date in ISO numeric only format

## ===== Change target sub routines to reflect your script ===== ##
if($expirydate > $licensetime) {&licenseOkay;}     # Take to Okay notice.
# if($expirydate > $licensetime) {&ANYSUBROUTINE;} # Replaces 'licenseOkay' with new target.
elsif ($expirydate <= $licensetime) {&expired;}    # Takes to expired notice.
}

sub expired {
# print "<meta http-equiv=refresh content='0; url=$expurl'>\n"; # META refresh to another page

## ===== Delete this if using external page ===== ##
print <<"EXPRD";
<div align="center">
Today's date is: $nowtime<br>
<br><div align="center" style="background:red; color:white; border:1px solid; padding:10; width:400;">
<b>Your License expired on:<br>$runsouton</b></div></div>
EXPRD
}

## ===== Delete this when using your target sub-routine ===== ##
sub licenseOkay {
print <<"ISOK";
<div align="center">
Today's date is: $nowtime<br>
<br><div align="center" style="background:lightblue; border:1px solid; padding:10; width:400;">
This license is good.<br>It expires on $runsouton</div></div>
ISOK
}
# end


Enjoy - Ted

Posted by admin (Graham Ellis), 28 June 2006
Ted, Thank you.

I'm in Dublin / hotel connection just at the moment so can't look and analyse in comforatble detail, but I happen to be starting work on a script with an expiry element over the next few days.   Think I'll start by looking at yours    - Graham

Posted by TedH (TedH), 28 June 2006
Have fun in Dublin Graham.

One thing readers may notice is that I've used a META redirect to the URL for an external page.

This should be okay as it is in a Perl script and search engine robots don't look there. Also it means you can use this on a Windows server as well.

Apache on a Unix based server has other methods of redirect available and they can be used if needed.

Or your expiry notice could simply be inside a/the Perl script. There's a lot of flexibility here.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho