Ma mauvaise fonction de découpage d'url

This commit is contained in:
Georges Dupéron 2010-07-05 12:11:44 +02:00
parent 641d7b7974
commit 08b9011475

View File

@ -7,4 +7,34 @@ function concaténer_chemin_fs($p1, $p2) {
return $p1 . '/' . $p2; // FIXME : . '/' . n'est pas portable !
}
?>
function split_uri($uri) {
$uri = urldecode($uri);
if (strpos($uri, 'https://') === 0) {
$split["protocole"] = 'https://';
$uri = substr($uri, 8);
$split["hote"] = substr($uri, 0, strpos($uri,'/'));
$uri = substr($uri, strpos($uri,'/'));
} else if (strpos($uri, 'http://') === 0) {
$split["protocole"] = 'http://';
$uri = substr($uri, 7);
$split["hote"] = substr($uri, 0, strpos($uri,'/'));
$uri = substr($uri, strpos($uri,'/'));
} else {
$split["protocole"] = '';
$split["hote"] = '';
}
$question_pos = strpos($uri, '?');
if ($question_pos === FALSE) {
$chemin = $uri;
$parametres = '';
} else {
$chemin = substr($uri, 0, $question_pos);
$parametres = substr($uri, $question_pos);
}
$split["chemin"] = explode('/', $chemin);
$split["parametres"] = explode('&', $parametres);
return $split;
}