A PHP utility function

Ukończone Opublikowano Jul 30, 2011 Płatność przy odbiorze
Ukończone 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.

PHP

Numer ID Projektu: #3477044

O projekcie

10 ofert Zdalny projekt Aktywny Aug 1, 2011

Przyznany użytkownikowi:

progwriter

See private message.

$51 USD w 1 dzień
(564 ocen)
7.6

10 freelancerów złożyło ofertę za $80 w tym projekcie

s17

See private message.

$76.5 USD w ciągu 1 dnia
(334 Oceny)
6.5
toinnisfreesl

See private message.

$42.5 USD w ciągu 1 dnia
(65 Oceny)
5.8
paulhutchnz

See private message.

$85 USD w ciągu 1 dnia
(68 Oceny)
5.1
whiteshadow

See private message.

$68 USD w ciągu 1 dnia
(18 Oceny)
4.6
freelancebritvw

See private message.

$84.99 USD w ciągu 1 dnia
(10 Oceny)
3.4
friendlytec

See private message.

$182.75 USD w ciągu 1 dnia
(3 Oceny)
3.3
UFS

See private message.

$84.15 USD w ciągu 1 dnia
(11 Oceny)
3.8
malaimovw

See private message.

$42.5 USD w ciągu 1 dnia
(0 Oceny)
0.0
alienaffili

See private message.

$85 USD w ciągu 1 dnia
(0 Oceny)
0.0