Skip to content

Commit f851682

Browse files
author
Christian
committed
fixed missing offset parameter for SEO API call
1 parent cc58bff commit f851682

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

seo.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
// Extract path and query information from current URL
2323
$url = parse_url($_SERVER['REQUEST_URI']);
2424
$path = $url['path'];
25-
$query = isset($url['query']) ? $url['query'] : "";
2625

2726
// search for rootpath in $path and remove it
2827
$key = str_replace("/".$config['rootpath'], "", $path);
29-
30-
// Append ?offset parameter if set
31-
if (strpos($query, 'offset=') !== false) {
32-
$key .= '?'.$query;
33-
}
3428
}
3529

3630
// escapes the key string
@@ -72,10 +66,29 @@ function fetchFromSeoApi($key, $url){
7266
}
7367
}
7468

69+
// Extract 'offset' param from given URL object
70+
function getOffsetParam(){
71+
$url = parse_url($_SERVER['REQUEST_URI']);
72+
$query = isset($url['query']) ? $url['query'] : "";
73+
74+
if(strpos($query, 'offset=') !== false) {
75+
$offset = $query;
76+
}
77+
else {
78+
$offset = '';
79+
}
80+
81+
return $offset;
82+
}
83+
7584
// Check if $key is already in the cache
7685
if(!is_file('cache/path_'.$escapedKey.'.php')){
7786
$debug_cache = "false";
7887

88+
// get offset of current URL
89+
$offset = getOffsetParam();
90+
$key .= !empty($offset) ? "?".$offset : "";
91+
7992
// build URL to fetch data from
8093
$url = $config['SEO_server'].$config['domain']."?url=".$key;
8194
$SEO_json = fetchFromSeoApi($key, $url);

0 commit comments

Comments
 (0)