- $activate = get_pconfig(local_user(),'jappixmini','activate');
- $dontinsertchat = get_pconfig(local_user(), 'jappixmini','dontinsertchat');
- if (!$activate || $dontinsertchat) return;
-
- $a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/jappix/php/get.php?t=js&g=mini.xml"></script>'."\r\n";
- $a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/jappix/php/get.php?t=js&f=presence.js~caps.js~name.js~roster.js"></script>'."\r\n";
-
- $a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/lib.js"></script>'."\r\n";
-
- $username = get_pconfig(local_user(),'jappixmini','username');
- $username = str_replace("'", "\\'", $username);
- $server = get_pconfig(local_user(),'jappixmini','server');
- $server = str_replace("'", "\\'", $server);
- $bosh = get_pconfig(local_user(),'jappixmini','bosh');
- $bosh = str_replace("'", "\\'", $bosh);
- $encrypt = get_pconfig(local_user(),'jappixmini','encrypt');
- $encrypt = intval($encrypt);
- $password = get_pconfig(local_user(),'jappixmini','password');
- $password = str_replace("'", "\\'", $password);
-
- $autoapprove = get_pconfig(local_user(),'jappixmini','autoapprove');
- $autoapprove = intval($autoapprove);
- $autosubscribe = get_pconfig(local_user(),'jappixmini','autosubscribe');
- $autosubscribe = intval($autosubscribe);
-
- // set proxy if necessary
- $use_proxy = get_config('jappixmini','bosh_proxy');
- if ($use_proxy) {
- $proxy = $a->get_baseurl().'/addon/jappixmini/proxy.php';
- }
- else {
- $proxy = "";
- }
-
- // get a list of jabber accounts of the contacts
- $contacts = Array();
- $uid = local_user();
- $rows = q("SELECT * FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' AND `k` LIKE 'id:%%'");
- foreach ($rows as $row) {
- $key = $row['k'];
- $pos = strpos($key, ":");
- $dfrn_id = substr($key, $pos+1);
- $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')",
- dbesc($dfrn_id),
- dbesc($dfrn_id)
- );
- if (count($r))
- $name = $r[0]["name"];
-
- $value = $row['v'];
- $pos = strpos($value, ":");
- $address = substr($value, $pos+1);
- if (!$address) continue;
- if (!$name) $name = $address;
-
- $contacts[$address] = $name;
- }
- $contacts_json = json_encode($contacts);
- $contacts_hash = sha1($contacts_json);
-
- // get nickname
- $r = q("SELECT `username` FROM `user` WHERE `uid`=$uid");
- $nickname = json_encode($r[0]["username"]);
- $groupchats = get_config('jappixmini','groupchats');
- //if $groupchats has no value jappix_addon_start will produce a syntax error
- if(empty($groupchats)){
- $groupchats = "{}";
- }
-
- // add javascript to start Jappix Mini
- $a->page['htmlhead'] .= "<script type=\"text/javascript\">
+ $a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/lib.js"></script>' . "\r\n";
+
+ $username = PConfig::get(local_user(), 'jappixmini', 'username');
+ $username = str_replace("'", "\\'", $username);
+ $server = PConfig::get(local_user(), 'jappixmini', 'server');
+ $server = str_replace("'", "\\'", $server);
+ $bosh = PConfig::get(local_user(), 'jappixmini', 'bosh');
+ $bosh = str_replace("'", "\\'", $bosh);
+ $encrypt = PConfig::get(local_user(), 'jappixmini', 'encrypt');
+ $encrypt = intval($encrypt);
+ $password = PConfig::get(local_user(), 'jappixmini', 'password');
+ $password = str_replace("'", "\\'", $password);
+
+ $autoapprove = PConfig::get(local_user(), 'jappixmini', 'autoapprove');
+ $autoapprove = intval($autoapprove);
+ $autosubscribe = PConfig::get(local_user(), 'jappixmini', 'autosubscribe');
+ $autosubscribe = intval($autosubscribe);
+
+ // set proxy if necessary
+ $use_proxy = Config::get('jappixmini', 'bosh_proxy');
+ if ($use_proxy) {
+ $proxy = $a->get_baseurl() . '/addon/jappixmini/proxy.php';
+ } else {
+ $proxy = "";
+ }
+
+ // get a list of jabber accounts of the contacts
+ $contacts = [];
+ $uid = local_user();
+ $rows = q("SELECT * FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' AND `k` LIKE 'id:%%'");
+ foreach ($rows as $row) {
+ $key = $row['k'];
+ $pos = strpos($key, ":");
+ $dfrn_id = substr($key, $pos + 1);
+ $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')", dbesc($dfrn_id), dbesc($dfrn_id));
+ if (count($r))
+ $name = $r[0]["name"];
+
+ $value = $row['v'];
+ $pos = strpos($value, ":");
+ $address = substr($value, $pos + 1);
+ if (!$address) {
+ continue;
+ }
+ if (!$name) {
+ $name = $address;
+ }
+
+ $contacts[$address] = $name;
+ }
+ $contacts_json = json_encode($contacts);
+ $contacts_hash = sha1($contacts_json);
+
+ // get nickname
+ $r = q("SELECT `username` FROM `user` WHERE `uid`=$uid");
+ $nickname = json_encode($r[0]["username"]);
+ $groupchats = Config::get('jappixmini', 'groupchats');
+ //if $groupchats has no value jappix_addon_start will produce a syntax error
+ if (empty($groupchats)) {
+ $groupchats = "{}";
+ }
+
+ // add javascript to start Jappix Mini
+ $a->page['htmlhead'] .= "<script type=\"text/javascript\">