Can you find CC Details on enteries and block them?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can you find CC Details on enteries and block them?

Post by simonmlewis »

We have having issues now whereby people are punching in their credit card details, ie. 5555 4444 5555 4444, asking for refunds on items.

Is there a way on the following page (which we have in place before it goes to a database) to check the contents for a specific style of entries, such as 4 continuous digits, and then asterisk them out?

So for example: "Dear john, please refund me my money straight away to credit card number 4567 8901 2345 6778", for them to see on the following page: "Dear john, please refund me my money straight away to credit card number **** **** **** ****", or "Dear john, please refund me my money straight away to credit card number **** 8901 2345 6778" or something similar?

The people who have done it so far, always do it in the correct format though, with the spacing. So may be a way to pick that out.

Hope someone can help.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can you find CC Details on enteries and block them?

Post by requinix »

You can use a regular expression to search for 16 digits in a row.

Wouldn't it be easier to put a message on the form saying "Please don't enter personal information such as addresses or credit card numbers on this page"?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you find CC Details on enteries and block them?

Post by simonmlewis »

Well yes, we tried that but a lot of youngers use the site, and have access to their parents CCs, and they appear to be a bit dippy!

Trouble is, 6666 6666 5555 5555 is not 16 digits in a row, as there are three spaces.

Or does that still count? What TERM should I look for in a PHP expression search for this type of query?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can you find CC Details on enteries and block them?

Post by Benjamin »

I wrote a quick and dirty snippet for you in order to get you started.

Code: Select all

<?php
echo '<pre>';
$text = "Please refund my purchase of $1.00 to credit card number 1234 4567 8901 2345, I no longer want this item, because it doesn't work.  Thank you.\n";
echo $text;

/*
 * Removes the first 12 digits of a 16 digit number.
 *
 * Matches:
 *
 * 1234 5678 9012 3456
 * 1234-5678-9012-3456
 * 1234567890123456
 */
$text = stripslashes(preg_replace('#^(.*?)((\d{4}[ -]{0,1})(\d{4}[ -]{0,1})(\d{4}[ -]{0,1})(\d{4}[ -]{0,1}))(.*)$#', '${1}************${6}${7}', preg_quote($text)));

echo "$text\n";
Outputs:

[text]Please refund my purchase of $1.00 to credit card number 1234 4567 8901 2345, I no longer want this item, because it doesn't work. Thank you.
Please refund my purchase of $1.00 to credit card number ************2345, I no longer want this item, because it doesn't work. Thank you.[/text]
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you find CC Details on enteries and block them?

Post by simonmlewis »

Sorry I might be being a bit dippy here, but that doesn't output that.
It just outputs everything including the numbers.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can you find CC Details on enteries and block them?

Post by Benjamin »

Click "Expand" to see all the code.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you find CC Details on enteries and block them?

Post by simonmlewis »

Oh my apologies. Didn't see that link. A new feature??

Will look at it and let you know how I get on.

Many thanks.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you find CC Details on enteries and block them?

Post by simonmlewis »

Using the same style of process, can this be used to filter out certain keywords?

ie. swear words?? If so, how do I do it?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply