From 46e09b05440fac8984ffc777b1dff4a765fcabf6 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Fri, 1 Dec 2017 22:55:48 -0500
Subject: [PATCH 1/2] Fix formatting
- dav
- jappixmini
- windowsphonepush
---
dav/friendica/dav_friendica_auth.inc.php | 39 +-
jappixmini/jappixmini.php | 668 ++++++++++++-----------
windowsphonepush/windowsphonepush.php | 337 +++++-------
3 files changed, 533 insertions(+), 511 deletions(-)
diff --git a/dav/friendica/dav_friendica_auth.inc.php b/dav/friendica/dav_friendica_auth.inc.php
index acc33fa1..31a88b68 100644
--- a/dav/friendica/dav_friendica_auth.inc.php
+++ b/dav/friendica/dav_friendica_auth.inc.php
@@ -1,41 +1,41 @@
currentUser);
- }
+ public function getUsers()
+ {
+ return array($this->currentUser);
+ }
/**
* @return null|string
*/
- public function getCurrentUser() {
- return $this->currentUser;
- }
+ public function getCurrentUser()
+ {
+ return $this->currentUser;
+ }
/**
* Authenticates the user based on the current request.
@@ -48,8 +48,8 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
* @throws Sabre_DAV_Exception_NotAuthenticated
* @return bool
*/
- public function authenticate(Sabre_DAV_Server $server, $realm) {
-
+ public function authenticate(Sabre_DAV_Server $server, $realm)
+ {
$a = get_app();
if (isset($a->user["uid"])) {
$this->currentUser = strtolower($a->user["nickname"]);
@@ -75,7 +75,6 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
return true;
}
-
/**
* @param string $username
* @param string $password
diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php
index 90499153..ba82a076 100644
--- a/jappixmini/jappixmini.php
+++ b/jappixmini/jappixmini.php
@@ -1,13 +1,12 @@
-*
-*/
-
+ * Name: jappixmini
+ * Description: Provides a Facebook-like chat using Jappix Mini
+ * Version: 1.0.1
+ * Author: leberwurscht
+ *
+ */
//
// Copyright 2012 "Leberwurscht"
//
@@ -16,141 +15,151 @@
/*
-Problem:
-* jabber password should not be stored on server
-* jabber password should not be sent between server and browser as soon as the user is logged in
-* jabber password should not be reconstructible from communication between server and browser as soon as the user is logged in
+ Problem:
+ * jabber password should not be stored on server
+ * jabber password should not be sent between server and browser as soon as the user is logged in
+ * jabber password should not be reconstructible from communication between server and browser as soon as the user is logged in
-Solution:
-Only store an encrypted version of the jabber password on the server. The encryption key is only available to the browser
-and not to the server (at least as soon as the user is logged in). It can be stored using the jappix setDB function.
+ Solution:
+ Only store an encrypted version of the jabber password on the server. The encryption key is only available to the browser
+ and not to the server (at least as soon as the user is logged in). It can be stored using the jappix setDB function.
-This encryption key could be the friendica password, but then this password would be stored in the browser in cleartext.
-It is better to use a hash of the password.
-The server should not be able to reconstruct the password, so we can't take the same hash the server stores. But we can
- use hash("some_prefix"+password). This will however not work with OpenID logins, for this type of login the password must
-be queried manually.
+ This encryption key could be the friendica password, but then this password would be stored in the browser in cleartext.
+ It is better to use a hash of the password.
+ The server should not be able to reconstruct the password, so we can't take the same hash the server stores. But we can
+ use hash("some_prefix"+password). This will however not work with OpenID logins, for this type of login the password must
+ be queried manually.
-Problem:
-How to discover the jabber addresses of the friendica contacts?
+ Problem:
+ How to discover the jabber addresses of the friendica contacts?
-Solution:
-Each Friendica site with this addon provides a /jappixmini/ module page. We go through our contacts and retrieve
-this information every week using a cron hook.
+ Solution:
+ Each Friendica site with this addon provides a /jappixmini/ module page. We go through our contacts and retrieve
+ this information every week using a cron hook.
-Problem:
-We do not want to make the jabber address public.
+ Problem:
+ We do not want to make the jabber address public.
-Solution:
-When two friendica users connect using DFRN, the relation gets a DFRN ID and a keypair is generated.
-Using this keypair, we can provide the jabber address only to contacts:
+ Solution:
+ When two friendica users connect using DFRN, the relation gets a DFRN ID and a keypair is generated.
+ Using this keypair, we can provide the jabber address only to contacts:
-Alice:
+ Alice:
signed_address = openssl_*_encrypt(alice_jabber_address)
-send signed_address to Bob, who does
+ send signed_address to Bob, who does
trusted_address = openssl_*_decrypt(signed_address)
save trusted_address
encrypted_address = openssl_*_encrypt(bob_jabber_address)
-reply with encrypted_address to Alice, who does
+ reply with encrypted_address to Alice, who does
decrypted_address = openssl_*_decrypt(encrypted_address)
save decrypted_address
-Interface for this:
-GET /jappixmini/?role=%s&signed_address=%s&dfrn_id=%s
+ Interface for this:
+ GET /jappixmini/?role=%s&signed_address=%s&dfrn_id=%s
-Response:
-json({"status":"ok", "encrypted_address":"%s"})
+ Response:
+ json({"status":"ok", "encrypted_address":"%s"})
-*/
+ */
+use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
+use Friendica\Model\User;
-function jappixmini_install() {
-register_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
-register_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
+function jappixmini_install()
+{
+ register_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
+ register_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
-register_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
-register_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
+ register_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
+ register_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
-register_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
+ register_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
-// Jappix source download as required by AGPL
-register_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
+ // Jappix source download as required by AGPL
+ register_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
-// set standard configuration
-$info_text = Config::get("jappixmini", "infotext");
-if (!$info_text) set_confConfig::setig("jappixmini", "infotext",
- "To get the chat working, you need to know a BOSH host which works with your Jabber account. ".
- "An example of a BOSH server that works for all accounts is https://bind.jappix.com/, but keep ".
- "in mind that the BOSH server can read along all chat messages. If you know that your Jabber ".
- "server also provides an own BOSH server, it is much better to use this one!"
-);
+ // set standard configuration
+ $info_text = Config::get("jappixmini", "infotext");
+ if (!$info_text)
+ set_confConfig::setig("jappixmini", "infotext", "To get the chat working, you need to know a BOSH host which works with your Jabber account. " .
+ "An example of a BOSH server that works for all accounts is https://bind.jappix.com/, but keep " .
+ "in mind that the BOSH server can read along all chat messages. If you know that your Jabber " .
+ "server also provides an own BOSH server, it is much better to use this one!"
+ );
-$bosh_proxy = Config::get("jappixmini", "bosh_proxy");
-if ($bosh_proxy==="") Config::set("jappixmini", "bosh_proxy", "1");
+ $bosh_proxy = Config::get("jappixmini", "bosh_proxy");
+ if ($bosh_proxy === "") {
+ Config::set("jappixmini", "bosh_proxy", "1");
+ }
-// set addon version so that safe updates are possible later
-$addon_version = Config::get("jappixmini", "version");
-if ($addon_version==="") Config::set("jappixmini", "version", "1");
+ // set addon version so that safe updates are possible later
+ $addon_version = Config::get("jappixmini", "version");
+ if ($addon_version === "") {
+ Config::set("jappixmini", "version", "1");
+ }
}
+function jappixmini_uninstall()
+{
+ unregister_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
+ unregister_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
-function jappixmini_uninstall() {
-unregister_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
-unregister_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
+ unregister_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
+ unregister_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
-unregister_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
-unregister_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
+ unregister_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
-unregister_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
-
-unregister_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
+ unregister_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
}
-function jappixmini_plugin_admin(&$a, &$o) {
+function jappixmini_plugin_admin(App $a, &$o)
+{
// display instructions and warnings on addon settings page for admin
-
if (!file_exists("addon/jappixmini.tgz")) {
$o .= '
The source archive jappixmini.tgz does not exist. This is probably a violation of the Jappix License (AGPL).
';
}
// warn if cron job has not yet been executed
$cron_run = Config::get("jappixmini", "last_cron_execution");
- if (!$cron_run) $o .= "
Warning: The cron job has not yet been executed. If this message is still there after some time (usually 10 minutes), this means that autosubscribe and autoaccept will not work.
";
+ if (!$cron_run) {
+ $o .= "
Warning: The cron job has not yet been executed. If this message is still there after some time (usually 10 minutes), this means that autosubscribe and autoaccept will not work.