Thanks solenoid, I added a modification just in case the url hasn't got any parameters
function modifyURL($mod)
{
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$query = explode("&", $_SERVER['QUERY_STRING']);
//NEW_CODE
$params = false;
if ( !empty($query) ){
$params = true;
}
// modify/delete data
foreach($query as $q) {
list($key, $value) = explode("=", $q);
if(array_key_exists($key, $mod)) {
if($mod[$key]) {
$url = preg_replace('/'.$key.'='.$value.'/', $key.'='.$mod[$key], $url);
} else {
$url = preg_replace('/&?'.$key.'='.$value.'/', '', $url);
}
}
}
// add new data
$params = "";
foreach($mod as $key => $value) {
if($value && !preg_match('/'.$key.'=/', $url)) {
//NEW_CODE
if ( $params ) {
$url .= '&'.$key.'='.$value;
} else {
$url .= '?'.$key.'='.$value;
$params = true;
}
}
}
return $url;
}
----
Server IP: 130.206.1.5
Probable Submitter: 213.201.24.165
----
Manual Page -- http://www.php.net/manual/en/function.parse-url.php
Edit -- https://master.php.net/note/edit/98125
Del: integrated -- https://master.php.net/note/delete/98125/integrated
Del: useless -- https://master.php.net/note/delete/98125/useless
Del: bad code -- https://master.php.net/note/delete/98125/bad+code
Del: spam -- https://master.php.net/note/delete/98125/spam
Del: non-english -- https://master.php.net/note/delete/98125/non-english
Del: in docs -- https://master.php.net/note/delete/98125/in+docs
Del: other reasons-- https://master.php.net/note/delete/98125
Reject -- https://master.php.net/note/reject/98125
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.