proxy: Simplify url extension extraction
This commit is contained in:
parent
c0ec9c5907
commit
1f94cb9aac
|
@ -281,15 +281,8 @@ function proxy_url($url, $writemode = false, $size = '') {
|
||||||
|
|
||||||
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
|
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
|
||||||
|
|
||||||
// Extract the URL extension, disregarding GET parameters starting with ?
|
// Extract the URL extension
|
||||||
$question_mark_pos = strpos($url, '?');
|
$extension = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
|
||||||
if ($question_mark_pos === false) {
|
|
||||||
$question_mark_pos = strlen($url);
|
|
||||||
}
|
|
||||||
$dot_pos = strrpos($url, '.', $question_mark_pos - strlen($url));
|
|
||||||
if ($dot_pos !== false) {
|
|
||||||
$extension = strtolower(substr($url, $dot_pos + 1, $question_mark_pos - ($dot_pos + 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$extensions = array('jpg', 'jpeg', 'gif', 'png');
|
$extensions = array('jpg', 'jpeg', 'gif', 'png');
|
||||||
if (in_array($extension, $extensions)) {
|
if (in_array($extension, $extensions)) {
|
||||||
|
|
Loading…
Reference in a new issue