File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 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
7685if (!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 );
You can’t perform that action at this time.
0 commit comments