Simple job for someone who knows Perl/CGI and has some familiarity with php.
Convert the short function below from php to Perl/CGI.
The function will be embedded into an existing Perl script to provide a very basic way of locking it to a specific domain by requiring a security code to be supplied in the script config file.
Existing php function ...
function CheckSecCode ($securitycode)
{
$domain = $_SERVER['SERVER_NAME'];
$domain = strtolower ($domain);
if (substr ($domain, 0, 4) == "www.") $domain = substr ($domain, 4);
$length = strlen ($domain);
if ($length > 16) $length = 16;
$codeddomain = "";
$lastval = 65;
for ($c = 0; $c < $length; $c++)
{
$chval = ord($domain[$c]) * 10) % 1000;
$codeddomain .= chr (($chval / 26) + 65);
$codeddomain .= chr (($chval % 26) + 65);
}
if ($securitycode != $codeddomain)
{
die ("<BR><BR><BR>Security code $securitycode is not correct for domain $domain");
}
}
Overview: The function gets the domain name of the server it is running on, chops off the "www." if present then creates a simple security code from the characters of the domain name by taking the ord() of each one and doing a very simple mathematical mapping.
This creates a code string for the domain name. If this generated string does not match the one passed to the function, the script dies with a simple message.
## Deliverables
The required delivery is an equivalent in Perl which can be embedded into a Perl script
- and when called, will exit the script if the security code passed to it is wrong.
All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Perl/CGI on Unix and Linux