Tag Archives: project - Page 2

[php] New Bing SERP checker using Windows Azure Datamarket

So, I got email from Bing Developer Team informing that Bing Search API 2.0 will be gone and moving to new platform: Windows Azure Datamarket. On my previous Bing SERP checker project, I’m using Bing Search API 2.0 which means that those codes will no longer working after 1st August.

Windows Azure Datamarket provide a trial package and a free package that has limit for 5000 requests per month. More than enough for us to toying for Bing SERP checker.

Go get your Account Key (was Application ID) : https://datamarket.azure.com/

This is the revised main function php codes so it will work on new Windows Azure Datamarket web service

How you call it:

Example output:

Fully working demo: http://demo.ahowto.net/new_bserp/

Actually, there are a lot of other “Search Market” that supported by Bing but I only listed some of them just for example. Download this document for complete list of Bing’s supported Search Market: http://www.bing.com/webmaster/content/developers/ADM_SCHEMA_GUIDE.docx

Notes:

  1. Your PHP version must be PHP 5.2 or higher (because of json_decode command)
  2. You must activate PHP OpenSSL module (php_openssl) because we are using file_get_contents and the webservice end point must be accessed via HTTPS

Update (2012-07-20) : the endpoint URL is changed

[php] Simple captcha alternative — using math question

Today, I received some task to implement some kind of captcha in some forms in hope that this captcha will reduce the garbage and automated submission. The client asked me to implement some user friendly captcha not those that hard to see. Re-Captcha and image based captcha (such as that I implemented in mp3 to Youtube‘s contact form) is not an option. Finally, the client decided to use captcha that ask visitors some simple math problem, i.e. addition and subtraction.

I remember that one of wordpress plugin had this kind of feature. I think it’s Contact Form 7. Oh, it’s actually Really Simple Captcha plugin. But there’s another huge problem. The website is not even a wordpress-based blog/site, it’s just simple site, probably created from ground-up using Dreamweaver. So, once again, installing a plugin is not an option.

After analyzing the requirements, I decided to create it myself. This is the simple captcha features that I created:

  • it use PHP session
  • the question is just a simple math addition or subtraction. No hard to see words or image
  • the number in the math problem is small (1 – 10), 4th grader would be easily solve the math problem
  • easily added to any existing PHP forms
  • works for PHP (non-CMS) based site.

The main code is saved in file named “scaptcha.php“. This is the full source codes:

Explanation:

First, it will start PHP session. $sentence array is used to store the sentences that will be seen by visitors before the math problem. You can edit it as you wish. $operands array is the math operand supported by this simple captcha script. The script then choose which sentence to be shown and the math operand randomly. Next, it will randomly choose 2 numbers between 1 and 10, operate it mathematically then store the result in PHP session.

The form that want to use this simple captcha have to include the file above (scaptcha.php).

Then, inside a form HTML element and –usually– exactly before form Submit button, these codes must be placed:

As you can see, the script simply show the random sentence, both numbers and operand to users then create a new text- type input where user can put it’s answer. The input text is named “answer“, you can change this if it’s already used in different form’s element name.

The target file (where the POST variables from the current form is sent and processed) must use session_start()in order to “catch” the “correct answer” of the simple captcha. Then compare the value between the correct answer saved in session and the user/visitor answer. If the answer is the same, then continue processing the form, if not, then show an error messages:

You have to match the $_POST[‘answer’] with the input text form’s element name generated by the script inside the previous form (only if you changed it to other names than ‘answer‘).

Full working demo can be tested here: http://demo.ahowto.net/scaptcha/

Online multi-currency converter mash-up

I’ve created Currency Converter Mash-up site that combine major currency converter source out there.
Site address: http://cconv.vrank.org/

Online Multi Currency Converter Screenshot

The results are taken from Google Finance currency converter, Yahoo! Finance currency converter, XE.com Universal Currency Converter, Western Union Currency Converter and Paypal. Western Union Currency Converter is quite useful if you had Google Adsense account which paid via Western Union, it gave gave you rough estimate how much will you get from Adsense in your local currency. Also, it would be useful for us that have USD currency in Paypal account but the goods that we will bought is in different currency e.g. EUR and GBP. Some source might provide less currency than others, read Currency Converter FAQ for more info.