A PHP utility function
$30-100 USD
Płatność przy odbiorze
garbleAndForward ($_POST, $destination)
This function will receive a typical $_POST array (from the web server) and a URL to forward the data to. You can use cUrl to forward the data, or just open a socket and send it if you prefer.
A static array called garbleRules will determine what to do with each of the fields in the $_POST array. The options are:
- remove => Just don't forward this to the destination
- garble-email => The value is an email address. It needs to be replaced with a different one (rules follow)
- garble-string => The value is an string. It needs to be replaced with a different one (rules follow)
All other fields NOT found in the configuration array are to be forwarded verbatim to the destination URL.
Rules for email addresses:
There will be a directory called /var/email_conversion/
When an email address that has never been processed before is requested for replacement, you generate a random string, and create a file called
/var/email_conversion/original_email (such as /var/email_conversion/name@[login to view URL])
that file will contain exactly one line that is the random replacement create before.
If the email address had already been processed, you just return the contents of that file, so each email address gets always the same replacement.
To generate the replacement string:
- signs are to be left where they are
- numbers are replaced by numbers
- uppercase letters are replaced by uppercase letters
- lowercase letters are replaced by lowercase letters
- the TLD part of the domain is not changed
For example, for this email address
MyEmail965@[login to view URL]
a valid transformation would be
XaJxaoe128@[login to view URL]
Rules for strings:
The first and last characters are left intact. The rest are transformed as follows:
- signs are to be left where they are
- All others are shuffled (moved in order), for example
Xabcdefg-hijklmZ
could be replaced by
Xfhicema-dbkljgZ
*
You also need to provide some unit tests, for example create some test $_POST arrays (hardcoded), and pass them to your function, to make sure they are transformed OK.
Numer ID Projektu: #3477044