Isset addr()
From Hak5
Isset_address() is a function that checks the URI for bar-set variables. It either detects any variable or one specified by the coder.
Instructions
For any variable: Use the "*" flag. Do not forget the quotation marks. For a specific variable: Use the variable name, omitting the $ sign. Right now, you can not check for many specific variables in one call of the function. Although an array may work, it has not been tested.
Code
<?PHP
/**********************************************/
/*Adresse-set variable Checker */
/*By Maxime Rousseau aka Max302 */
/*http://www.maximerousseau.com/ */
/*--------------------------------------------*/
/*Checks the addresse bar of the */
/*current page for your choice of */
/*a variable of your choice or any */
/*var at all. */
/*Liscensed under BeerWare. */
/*----http://en.wikipedia.org/wiki/Beerware---*/
/**********************************************/
function isset_addr($vartocheck)
{
$addr = $_SERVER['REQUEST_URI'];
if ($vartocheck == "*") //Checks any addresse set variable.
{
$check = stripos($addr,"?"); //Checks adresse for the php addresse line declaration character.
if ($check >= 1)
{
return(1);
}
else
{
return(0);
}
}
else if ($vartocheck != 0 && $vartocheck != "*") //Checks if the var to check is set, then proceeds to processing check
{
$vartocheckwq = "?".$vartocheck; //Adds "?" for check Ex.: "/page.php?var=foo" returns 1 because "?var" is found
$vartocheckwa = "&".$vartocheck; //Adds "&" for check Ex.: "/page.php?var=foo&bar=some" returns 1 because
$checkwq = stripos($addr,$vartocheckwq); //Checks adresse for the php addresse line declaration character.
$checkws = stripos($addr,$vartocheckwa);
if ($checkwq >= 1 || $checkwa >= 1) //If any of the stripos() checks are positive.
{
return(1);
}
else
{
return(0);
}
}
else
{
echo "<b>PHP Error:</b> Not enough variables supplied for function <b>ISSET_ADDR()</b>"; //Error message if no var-check flag is declared
}
}
?>
Usage
For any of your open source work, please leave the header intact. This is licensed under beerware.


