<?php

function process_path_info() {
    if (empty($_SERVER['PATH_INFO'])) {
        return;
    }
    $a = explode('/', $_SERVER['PATH_INFO']);
    $b = 1;
    $c = count($a) - 1;
    if (get_magic_quotes_gpc()) {
        while ($b < $c) {
	    if (is_numeric($a[$b])) {
		$b++;		
		continue;
	    }
            $_GET[stripslashes($a[$b])] = stripslashes($a[$b + 1]);
            $b += 2;
        }
    } else {
        while ($b < $c) {
	    if (is_numeric($a[$b])) {
		$b++;
		continue;
	    }
            $_GET[$a[$b]] = $a[$b + 1];
            $b += 2;
        }
    }
    if ($b === $c) {
        $_GET['_URI_EXTRA'] = $a[$b];
    }
}

function strip_slashes_from_user_data(&$array) {
    foreach($array as $k => $v) {
        if (is_array($v)) {
            strip_slashes_from_user_data($array[$k]);
            continue;
        }
        $array[$k] = stripslashes($v);
    }
}

if (get_magic_quotes_gpc()) {
    strip_slashes_from_user_data($_GET);
    strip_slashes_from_user_data($_POST);
    strip_slashes_from_user_data($_COOKIE);
}
process_path_info();

?>
