Posts

Showing posts from June, 2010

PHP Payment Library for Paypal, Authorize.net and 2Checkout

If you are like me, whenever you need to work with a 3rd party API or a gateway, you’d first search in Google for a possible wrapper for it in PHP. When it comes to supporting payment gateways, you get bunch of libraries in the search results who are fundamentally different. Some of them are old PHP 3/4 ones, some are new, some may need PEAR, etc. As they were not required together in one single project, I used them whenever needed. But in one project, I needed them all. I thoughts it’s a chance and decided to stop using them and wrote my own ones where I can use the same methods for all the gateways So, here is an abstract PaymentGateway library which is being extended to be used for three popular payment gateways ( Paypal , Authorize.net , and 2Checkout ) in order to provide you with a similar way of using them. Note that the libraries are for basic usage only and do not contain options for recurring payments. Without much babble, let’s see a few examples of how you ca

bad word filter script in php

This is a simple file based bad word filter PHP function. The function offers a variety of options. You can choose how many letters of the bad word you wish to keep, which character you want to use as the badword "bleeper" as well as a rating for the bad word. The bad words file would be formatted like this: 9   badword 2   anther badword 7   A bad word Phrase 7   YetAnotherWord The first character number is the bad word "rating" the higher the number the worse the word. This can be useful in say, a forum situation where a user can specify their bad word tolerance. So if I pass the function a bad word tolerance of 5, the function will only remove words with a tolerance rating higher than 5. A sample function call would look like this: $myString = "This is a sentence with some badwords, It is an example based on the Yetanotherword file above."; echo filterBadWords($myString,"badwords.txt","*",1,3); If our above badword