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');
13 register_hook('ping_xmlize', 'addon/convpath/convpath.php', 'convpath_ping_xmlize_hook');
14 register_hook('prepare_body', 'addon/convpath/convpath.php', 'convpath_prepare_body_hook');
15 register_hook('display_item', 'addon/convpath/convpath.php', 'convpath_display_item_hook');
19 function convpath_uninstall() {
20 unregister_hook('page_end', 'addon/convpath/convpath.php', 'convpath_page_end');
21 unregister_hook('page_header', 'addon/convpath/convpath.php', 'convpath_page_header');
22 unregister_hook('ping_xmlize', 'addon/convpath/convpath.php', 'convpath_ping_xmlize_hook');
23 unregister_hook('prepare_body', 'addon/convpath/convpath.php', 'convpath_prepare_body_hook');
24 unregister_hook('display_item', 'addon/convpath/convpath.php', 'convpath_display_item_hook');
27 function convpath_ping_xmlize_hook(&$a, &$o) {
28 $o["photo"] = convpath_url($a, $o["photo"]);
31 function convpath_page_header(&$a, &$o){
32 $o = convpath_convert($o);
35 function convpath_page_end(&$a, &$o){
36 $o = convpath_convert($o);
37 $a->page['aside'] = convpath_convert($a->page['aside']);
40 function convpath_prepare_body_hook(&$a, &$o) {
41 $o["html"] = convpath_convert($o["html"]);
44 function convpath_display_item_hook(&$a, &$o) {
45 if (isset($o["output"])) {
46 if (isset($o["output"]["thumb"]))
47 $o["output"]["thumb"] = convpath_url($a, $o["output"]["thumb"]);
48 if (isset($o["output"]["author-avatar"]))
49 $o["output"]["author-avatar"] = convpath_url($a, $o["output"]["author-avatar"]);
50 if (isset($o["output"]["owner-avatar"]))
51 $o["output"]["owner-avatar"] = convpath_url($a, $o["output"]["owner-avatar"]);
52 if (isset($o["output"]["owner_photo"]))
53 $o["output"]["owner_photo"] = convpath_url($a, $o["output"]["owner_photo"]);
57 function convpath_url($a, $path) {
61 $ssl = (substr($a->get_baseurl(), 0, 8) == "https://");
64 $search = "http://".$a->get_hostname();
65 $replace = "https://".$a->get_hostname();
67 $search = "https://".$a->get_hostname();
68 $replace = "http://".$a->get_hostname();
71 $path = str_replace($search, $replace, $path);
77 Converts a given path according to the current scheme
79 function convpath_convert($path) {
85 $ssl = (substr($a->get_baseurl(), 0, 8) == "https://");
88 $search = "http://".$a->get_hostname();
89 $replace = "https://".$a->get_hostname();
91 $search = "https://".$a->get_hostname();
92 $replace = "http://".$a->get_hostname();
94 $searcharr = array("src='".$search, 'src="'.$search);
95 $replacearr = array("src='".$replace, 'src="'.$replace);
96 $path = str_replace($searcharr, $replacearr, $path);
98 //$path = str_replace($search, $replace, $path);