Important alert: (current site time 7/15/2013 10:13:30 AM EDT)
 

VB icon

Custom URL Query Formatter

Email
Submitted on: 6/26/2004 5:09:54 PM
By: Josh St. Marie  
Level: Advanced
User Rating: By 2 Users
Compatibility: PHP 4.0
Views: 8250
author picture
(About the author)
 
     This code changes the standard URL queries. You can change the regular '&' and '=' to new characters. This makes it look more cool, and can actually increase security because a bot could try url queries with different seperators and they wouldnt work.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Custom URL Query Formatter
// Description:This code changes the standard URL queries. You can change the regular '&' and '=' to new characters. This makes it look more cool, and can actually increase security because a bot could try url queries with different seperators and they wouldnt work.
// By: Josh St. Marie
//
// Returns:The function returns an array you can use in place of $_GET
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1400&lngWId=8//for details.//**************************************

# Two constants need to be defined in order for
# the script to work.
# The character you wish to use to seperate
# values from variables
define('QUERY_VALUE_SEP','=');
# The character you wish to use bewteen sets of
# variables and values.
define('QUERY_VAR_SEP','&');
# This is the function to process the URL query.
function getVars ()
{
 $get_vars = array();
 if(isset($_SERVER['QUERY_STRING']))
 {
$variables = explode(QUERY_VAR_SEP,$_SERVER['QUERY_STRING']);
foreach($variables as $k)
{
 $parts[] = explode(QUERY_VALUE_SEP,$k);
}
$parts_size = sizeof($parts);
 }
		
 for($i = 0; $i < $parts_size; $i++)
 {
if(!isset($parts[$i][0]) || !isset($parts[$i][1]))
 break;
$get_vars[$parts[$i][0]] = $parts[$i][1];
 }
 return $get_vars;
}
# Call getVars() at the top of your page.
# Example:
$get_vars = getVars();
# Then you don't use $_GET, you now use $get_vars to fetch URL query variables and values.
# With this simple script, you can change the URL
# query from the regular boring '&' and '='
# characters, for one, it makes it look more
# trendy, and, it can increase security if bots
# try regular queries, they'll be ignored by your
# script which makes use of a new format
# For example if QUERY_VALUE_SEP was '.' and 
# QUERY_VAR_SEP was ';' then your url queries 
# would look like:
# index.php?variable.1;variable.testinfo


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
7/19/2004 3:27:21 AMBelgiumBoy_007

Wouldn't this do the same:

str_replace ("&", ";", $_SERVER['QUERY_STRING']);

?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.