4 * Description: Converts all internal paths according to the current scheme (http or https)
6 * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
10 function convpath_install() {
11 register_hook('page_end', 'addon/convpath/convpath.php', 'convpath_page_end');
12 register_hook('page_header', 'addon/convpath/convpath.php', 'convpath_page_header');
16 function convpath_uninstall() {
17 unregister_hook('page_end', 'addon/convpath/convpath.php', 'convpath_page_end');
18 unregister_hook('page_header', 'addon/convpath/convpath.php', 'convpath_page_header');
21 function convpath_page_header(&$a, &$o){
22 $o = convpath_convert($o);
25 function convpath_page_end(&$a, &$o){
26 $o = convpath_convert($o);
27 $a->page['aside'] = convpath_convert($a->page['aside']);
31 Converts a given path according to the current scheme
33 function convpath_convert($path) {
39 $ssl = (substr($a->get_baseurl(), 0, 8) == "https://");
42 $search = "http://".$a->get_hostname();
43 $replace = "https://".$a->get_hostname();
45 $search = "https://".$a->get_hostname();
46 $replace = "http://".$a->get_hostname();
48 $searcharr = array("src='".$search, 'src="'.$search);
49 $replacearr = array("src='".$replace, 'src="'.$replace);
50 $path = str_replace($searcharr, $replacearr, $path);
52 //$path = str_replace($search, $replace, $path);