This is a class to use together with apache <ForceType> directives (in .htaccess or httpd.conf) to give your site nice looking urls for dynamic pages.
As an example, take the scripts section of this site. Instead of urls that look like:
it has urls like:
For more information on how this is done, read the tutorials listed in the links section.
What friendlyurls does
All that this class does is get the parts of the url that aren't real, and puts them in a nice array that you can use as arguments or whatever in your script.
Quote from .htaccess file:
These lines tell apache that it should treat the file called scripts as if it was a php file.
The scripts file:
include("friendlyurls.php"); // include the class
$ft = new friendlyurls("/[^\/]*(\.[^\/]*)/", "");
the (optional) argument to the constructor is a regular expression telling the class to strip out
any parts of the url that are file extensions (eg .htm)
the friendlyurls object now contains two arrays:
$arguments, which contains all parts of the url after /scripts/
and $arguments_slashed which contains the same, but in a database safe addslashes() format
$scripts = isset($ft->arguments_slashed) ? $ft->arguments_slashed : "";
// $scripts should now contain the name of the script to show info on
$scriptdetails = mysql_query("SELECT * FROM scripts WHERE title='$scripts'");
// display the script details
I probably haven't explained this very well. Try asking in the support forum.
$furl = new friendlyurl($search, $replace, $noduplicates = true, $noquerystring = true)
$search is a PCRE regular expression to search for in the parts of the url
$replace is what to replace them with
$noduplicates means that each keyword is only listed once,
would result in the $arguments array containing:
"cat", "dog", "fish" if $noduplicates was true
and "cat", "dog", "cat", "fish" if $noduplicates is false
$noquerystring means that any querystring is not included
After the class is created, the following member variables can be accessed:
$arguments an array of all the words between /'s after the script name
$arguments_slashed the same array with addslashes() applied to each item
$arguments_count the number of items in the $arguments arrays