Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Spell Checking and URL Tricks
Now change the "bogus" part of the url to some other word. This is how this was done:
In my Apache server configuration I have this:

<Location /s>
ForceType application/x-httpd-php3
</Location>
Then I created a file named simply 's' and placed it in my document root. The file contains:

<html><head><title>Simple Spell-Checker</title></head>
<body>
<h3>Simple Spell-Checker</h3>
<?php
    $aspell_link
=aspell_new("english");
    
$word = substr($PATH_INFO,1); /* strip away first / */
    
if (aspell_check($aspell_link,$word)) {
        echo
"Correct spelling of '$word'<P>\n";
    } else {
        echo
"Incorrect spelling of '$word'<P>\n";
    }
    echo
"Possible correct spellings include:<br>\n";
    
$suggestions=aspell_suggest($aspell_link,$word);
    for(
$i=0; $i < count($suggestions); $i++) {
        echo
"<li>" . $suggestions[$i] . "<br>";
    }
    echo
"</ol>";
?>
</body></html>
The trick here is that by telling Apache that the /s resource is actually of MIME type application/x-httpd-php3 which is the magical MIME type which triggers PHP, the s file will be run like a PHP script. Any text in the URL following the /s will be put into the $PATH_INFO variable. So in my script I just strip away the first slash and then treat the remaining text as the word I want to spell check.
A couple of other variables get set to useful things on a request like this. Our /s/bogus request from above results in the following:
SCRIPT_FILENAME = /home/httpd/html/s
REQUEST_URI = /s/bogus
SCRIPT_NAME = /s
PATH_INFO = /bogus
PATH_TRANSLATED = /home/httpd/html/bogus
You can of course discover this yourself by putting a <phpinfo()> tag in your script and loading it up.
Now, for the spell checking part of this. There isn't much to it. You can read about the functions used here:
http://www.phpbuilder.com/manual/ref.aspell.php
If you don't have aspell enabled, download the aspell tarball and install it. Note that version 0.27 does not work with PHP since the author did not include a C-callable library. Version 0.26 works fine. The author has promised to bring back the C-callable library in a future version.
-Rasmus

[Page 1]  [Page 2]  


Comments:
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÇýÁø12/02/04 06:04
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæ¿í12/02/04 00:12
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø11/30/04 03:48
Áß¿äÇÑ Á¤º¸ÀÔ´Ï´ÙÀÌ´ÙÇö11/27/04 05:36
½Å.¿ë.ºÒ.·®/Ä«.µå.¿¬.ü/´ë.Ãâ/È¥ÀÚ/ÇØ.°áÇÏ´Â/¹æ.¹ý±èÇö¼­11/24/04 23:51
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÇýÁø11/24/04 01:12
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæÇý11/21/04 08:15
½Å.¿ëºÒ.·®ÀÚ°¡ ¾Ë¾Æ¾ßÇÒ Á¤.º¸ ´ë.°ø.°³ ÀÌ´ÙÁø11/16/04 21:38
Ä«.µå °ª.¿ø.±Ý.¸¸.°±.´Â.¹æ.¹ý(°­.Ãß)Áö¿µÈñ11/15/04 12:38
Ä«.µå.±ø.¾È.ÇÏ.°í.µ·.¸¸.µé.¾î.¾².´Â.ºñ.¹ýÀÌÈñÁø11/13/04 09:21
´ëÃâ °ÅÀý½Ã 100%µÇ°Ô ÇÏ´Â ¹æ¹ý(Çʵ¶)!!!±èÁö¿¬02/01/04 04:45
½Å¿ëºÒ·®ÀÚ 2³âµÚ ¿ø±Ý¸¸ °±´Â ¹æ¹ý!(Çʵ¶)±è¼÷Èñ01/06/04 01:00
Nice but...Clemens10/22/02 12:40
RE: How to do it for IIS?Ryan10/15/02 10:42
This threadJeff Sampson07/24/02 15:22
An other option ..Spacecat06/30/02 00:42
RE:Don't have any access to modify httpd.confPHP NEWBIE05/13/02 19:23
How to do it for IIS?Gary Loescher05/07/02 10:19
RE: Don't have any access to modify httpd.confMark04/25/02 22:55
send e-mail with specific information from DBMaher Salam04/21/02 20:08
RE: Writing an email programnido03/12/02 02:17
pspellgroundup02/28/02 23:17
problem in configuring aspellprasad11/30/01 07:40
Need HelpDon09/04/01 22:42
need helpnerd08/28/01 05:53
RE: No input fileBill Peck06/07/01 16:54
RE: Writing an email programDave05/14/01 03:47
Don't have any access to modify httpd.confTeo Danardi03/09/01 14:22
No input fileRavis12/18/00 05:44
RE: Writing an email programNath11/29/00 05:04
Writing an email programNeville Lewis11/16/00 10:41
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.