Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Sunday, May 10, 2009

Vidoop Flyout Captcha - Making it work

Vidoop Captcha (see implementation here) is an awesome thing for normal validation.
And even more awesome is the flyout version of it, which doesn't strip away the visual appeal of your page.

Implementing the flyout version is a bit confusing, primarily because there is a single document for this, and that too gets repetitive but misses out on the major details. I thought I could do better.

Here is a step-by-step how-to to making Vidoop Flyout work with your website (and also the automatic changes it makes to your page)

#1: Find the normal Vidoop Secure Captcha code implementation on your page. It should resemble this (note that the image src, categories to look for, and captcha_id would be different for you)
<form method="get">
<img src="https://api.vidoop.com/vs/captchas/IT42FKE7FE/image" />
<p>Type in the 3 letters you see on pictures of <span class="category_name">money</span>, <span class="category_name">birds</span>, and <span class="category_name">computers</span>, in that order.</p>
<input type="input" name="code" value="" />
<input type="hidden" name="captcha_id" value="IT42FKE7FE" />
<input type="submit" name="submit" value="Submit" />
</form>

#2: Wrap the image code and instructions in a <noscript> tag. This would be the non-flyout version of captcha that shows up when JS is disabled. Let the remaining code untouched.
<noscript>
<img src="https://api.vidoop.com/vs/captchas/IT42FKE7FE/image" />
<p>Type in the 3 letters you see on pictures of <span class="category_name">money</span>, <span class="category_name">birds</span>, and <span class="category_name">computers</span>, in that order.</p> </noscript>


#3: Include the jQuery library in your HTML file (can be placed anywhere). jQuery will give you the slick effects.
<script type="text/javascript" src="http://com.vidoop.demo-static.s3.amazonaws.com/js/jquery-1.2.6.min.js"></script>


#4: Include the code to initialise the flyout Vidoop captcha (place this before the <noscript> tag for best effect). The 'flyout.js' is the script that does it, and inserts the necessary HTML and styling into the page. The inline script, where we declare the vidoop_secure variable is essential to working of the whole thing, as well as provides configuration parameters (rip open the flyout script in some text editor to learn about that).
<script type="text/javascript">
var vidoop_secure = {
instructions: 'Type in the 3 letters you see on pictures of <span class="category_name">money</span>, <span class="category_name">airplanes</span>, and <span class="category_name">houses</span>, in that order.',
};
</script>
<script type="text/javascript" src="js/flyout-0.9.12.js"></script>


#5: So now your main block of HTML looks like this
<form method="get">
<script type="text/javascript" src="http://com.vidoop.demo-static.s3.amazonaws.com/js/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
var vidoop_secure = {
instructions: 'Type in the 3 letters you see on pictures of <span class="category_name">money</span>, <span class="category_name">airplanes</span>, and <span class="category_name">houses</span>, in that order.',
};
</script>
<script type="text/javascript" src="js/flyout-0.9.12.js"></script>

<noscript>
<img src="https://api.vidoop.com/vs/captchas/IT42FKE7FE/image" />
<p>Type in the 3 letters you see on pictures of <span class="category_name">money</span>, <span class="category_name">birds</span>, and <span class="category_name">computers</span>, in that order.</p> </noscript>
<input type="input" name="code" value="" />
<input type="hidden" name="captcha_id" value="IT42FKE7FE" />
<input type="submit" name="submit" value="Submit" />
</form>

And now you have the Vidoop Secure flyout captcha working on your own site.

Sunday, September 21, 2008

iGoogle Sandbox for OpenSocial gadgets

#1: Register for your testing grounds http://www.google.com/ig/sandbox/

#2: Install the Developer Tools gadget and set up your optimal environment
http://tinyurl.com/5vwwaz
http://code.google.com/apis/igoogle/docs/igoogledevguide.html#dev_env

#3: Add demo friends (real people who sign up for your sandbox), if your gadget goes into the social realm and requests friends lists through API.(*)

#4: Use GGE (Google Gadget Editor) to write your experimental gadgets. Saves the trouble of uploading files to your own server, decent interface.
http://code.google.com/apis/igoogle/docs/igoogledevguide.html#gge

#5: Upload/manage gadgets through the 'My Gadgets' gadget that becomes visible after you've configured developer env (see #2)
Tip: If you're modifying and testing continuously, TURN OFF CACHING for your gadget


*: Currently, the iGoogle sandbox friends gadget is not working. It's not sending out any invitations or showing me the list of friends I've invited. I don't know what the devs get by ignoring the bug at the very entry point.

Thursday, May 8, 2008

PHP Woes: Getting pspell to work

The pspell extension allows some language tools like spell checking and similar-word recommendations.

To get pspell working, Aspell is required. Aspell is an OpenSource spellchecker, that has become the preferred one, replacing pspell and Ispell. Only the name remains, pspell functions in PHP are waiting to be renamed to Aspell ones.

I'm listing out the following steps for a Windows-specific installation. This has nothing to do with the server you're using (IIS or Apache)


  1. Get the Windows port of Aspell from http://aspell.net/win32/ (v0.50.3 installer here)
  2. Alongside, download a language dictionary as well (English dictionary here)
  3. Install Aspell followed by the language dictionary

  4. Make aspell-15.dll and pspell-15.dll available to PHP by either
    • Adding your Aspell bin directory (C:/Program Files/Aspell/bin in my case) to system's PATH variable OR
    • Copying the files to your PHP folder (C:/PHP in my case), if your PHP folder is already listed in PATH variable OR
    • Copying the files to windows folder (C:/Windows/) or system folder (C:/Windows/System32/)

  5. Enable the pspell extension in your php.ini file
    • Open your php.ini (generally in the PHP root folder or in Windows folder)
    • Firstly, make sure you have pspell.dll in your extentions folder (configured by variable 'extension_dir' in php.ini)
    • scroll down to where your extensions are listed, and decomment (remove the semicolon) so it looks like extension=php_pspell.dll - doing so enables the extension
    • Parsing of the ini file is cranky on some systems, so make sure that the above line goes to top of other commented/disabled extentions.


  6. Restart your server. It reloads the PHP module, which in turn reads the ini file and loads respective extensions again.

  7. Test if working: Saving as little code as <?php $pspell = pspell_new('en'); ?> in a script, and executing the script should do it.