function hotpot_convert_relative_url($baseurl, $reference, $opentag, $url, $closetag, $stripslashes = true) { if ($stripslashes) { $opentag = hotpot_stripslashes($opentag); $url = hotpot_stripslashes($url); $closetag = hotpot_stripslashes($closetag); } // catch <PARAM name="FlashVars" value="TheSound=soundfile.mp3"> // ampersands can appear as "&", "&" or "&#x0026;amp;" if (preg_match('|^' . '\\w+=[^&]+' . '(' . '&((amp;#x0026;)?amp;)?' . '\\w+=[^&]+)*' . '$|', $url)) { $query = $url; $url = ''; $fragment = ''; // parse the $url into $matches // [1] path // [2] query string, if any // [3] anchor fragment, if any } else { if (preg_match('|^' . '([^?]*)' . '((?:\\?[^#]*)?)' . '((?:#.*)?)' . '$|', $url, $matches)) { $url = $matches[1]; $query = $matches[2]; $fragment = $matches[3]; // these appears to be no query or fragment in this url } else { $query = ''; $fragment = ''; } } if ($url) { $url = hotpot_convert_url($baseurl, $reference, $url, false); } if ($query) { $search = '#' . '(file|src|thesound|mp3)=' . "([^&]+)" . '#ise'; $replace = "'\\1='.hotpot_convert_url('" . $baseurl . "','" . $reference . "','\\2')"; $query = preg_replace($search, $replace, $query); } $url = $opentag . $url . $query . $fragment . $closetag; return $url; }
function callback_url(&$matches) { return hotpot_convert_url($this->get_baseurl(), $this->reference, $matches[1], false); }