كود PHP:
<?php function variables_from_uri($separator=",", $cvs_allowed_vars='') { /** Set variables from Search Engine friendly URLs. Copyright 2000,2002 Jeremy Brand <jeremy@nirvani.net> [url]http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html[/url] Variables from URI for PHP. Release 1.0.1 [url]http://www.nirvani.net/software/[/url] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA INSTRUCTIONS FOR USE: Where $PATH_INFO is /living,1/login,nirvani/color,yellow This would set $living= '1', $login = 'nirvani' and $color = 'yellow' iff living, login and color are in the $cvs_allowed_vars string. ChangeLog: Jeremy Brand <jeremy@nirvani.net> 1.0.1 -- allow for use on servers that do not register globals. **/ global $HTTP_SERVER_VARS; $PATH_INFO = $HTTP_SERVER_VARS['PATH_INFO']; /** This is so you can pass in an array if you want ** instead of a comma delimited string **/ if (is_array($cvs_allowed_vars)) $allowed = $cvs_allowed_vars; else $allowed = explode(',',$cvs_allowed_vars); if(!count($allowed)) { print "no allowed variables<br>\n"; return FALSE; } $chunks = explode('/',$PATH_INFO); $num_chunks = count($chunks); for ($i=1; $i<$num_chunks; $i++) { if (ereg($separator,$chunks[$i])) { $tmp = explode($separator,$chunks[$i]); $var = $tmp[0]; $val = $tmp[1]; if (in_array($var, $allowed)) { global $$var; $$var = $val; } unset($tmp); unset($var); unset($val); } } return TRUE; }?>
لعيون حبايب سوالف