+ * published under GPL
+ *
+ * Latest version of the original script for joomla is available at:
+ * http://87.230.15.86/~dado/ejabberd/joomla-login
+ *
+ * Installation:
+ *
+ * - Change it's owner to whichever user is running the server, ie. ejabberd
+ * $ chown ejabberd:ejabberd /path/to/friendica/scripts/auth_ejabberd.php
+ *
+ * - Change the access mode so it is readable only to the user ejabberd and has exec
+ * $ chmod 700 /path/to/friendica/scripts/auth_ejabberd.php
+ *
+ * - Edit your ejabberd.cfg file, comment out your auth_method and add:
+ * {auth_method, external}.
+ * {extauth_program, "/path/to/friendica/script/auth_ejabberd.php"}.
+ *
+ * - Restart your ejabberd service, you should be able to login with your friendica auth info
+ *
+ * Other hints:
+ * - if your users have a space or a @ in their nickname, they'll run into trouble
+ * registering with any client so they should be instructed to replace these chars
+ * " " (space) is replaced with "%20"
+ * "@" is replaced with "(a)"
+ *
+ */
+
+namespace Friendica\Util;
+
+use Friendica\Core\Config;
+use Friendica\Core\PConfig;
+use Friendica\Database\DBM;
+use dba;
+
+require_once 'include/dba.php';
+
+class ExAuth
+{
+ private $bDebug;
+
+ /**
+ * @brief Create the class
+ *
+ * @param boolean $bDebug Debug mode
+ */
+ public function __construct()
+ {
+ $this->bDebug = (int) Config::get('jabber', 'debug');
+
+ openlog('auth_ejabberd', LOG_PID, LOG_USER);
+
+ $this->writeLog(LOG_NOTICE, 'start');
+ }
+
+ /**
+ * @brief Standard input reading function, executes the auth with the provided
+ * parameters
+ *
+ * @return null
+ */
+ public function readStdin()
+ {
+ while (!feof(STDIN)) {
+ // Quit if the database connection went down
+ if (!dba::connected()) {
+ $this->writeLog(LOG_ERR, 'the database connection went down');
+ return;
+ }
+
+ $iHeader = fgets(STDIN, 3);
+ $aLength = unpack('n', $iHeader);
+ $iLength = $aLength['1'];
+
+ // No data? Then quit
+ if ($iLength == 0) {
+ $this->writeLog(LOG_ERR, 'we got no data, quitting');
+ return;
+ }
+
+ // Fetching the data
+ $sData = fgets(STDIN, $iLength + 1);
+ $this->writeLog(LOG_DEBUG, 'received data: ' . $sData);
+ $aCommand = explode(':', $sData);
+ if (is_array($aCommand)) {
+ switch ($aCommand[0]) {
+ case 'isuser':
+ // Check the existance of a given username
+ $this->isUser($aCommand);
+ break;
+ case 'auth':
+ // Check if the givven password is correct
+ $this->auth($aCommand);
+ break;
+ case 'setpass':
+ // We don't accept the setting of passwords here
+ $this->writeLog(LOG_NOTICE, 'setpass command disabled');
+ fwrite(STDOUT, pack('nn', 2, 0));
+ break;
+ default:
+ // We don't know the given command
+ $this->writeLog(LOG_NOTICE, 'unknown command ' . $aCommand[0]);
+ fwrite(STDOUT, pack('nn', 2, 0));
+ break;
+ }
+ } else {
+ $this->writeLog(LOG_NOTICE, 'invalid command string ' . $sData);
+ fwrite(STDOUT, pack('nn', 2, 0));
+ }
+ }
+ }
+
+ /**
+ * @brief Check if the given username exists
+ *
+ * @param array $aCommand The command array
+ */
+ private function isUser(array $aCommand)
+ {
+ $a = get_app();
+
+ // Check if there is a username
+ if (!isset($aCommand[1])) {
+ $this->writeLog(LOG_NOTICE, 'invalid isuser command, no username given');
+ fwrite(STDOUT, pack('nn', 2, 0));
+ return;
+ }
+
+ // Now we check if the given user is valid
+ $sUser = str_replace(array('%20', '(a)'), array(' ', '@'), $aCommand[1]);
+
+ // Does the hostname match? So we try directly
+ if ($a->get_hostname() == $aCommand[2]) {
+ $this->writeLog(LOG_INFO, 'internal user check for ' . $sUser . '@' . $aCommand[2]);
+ $found = dba::exists('user', ['nickname' => $sUser]);
+ } else {
+ $found = false;
+ }
+
+ // If the hostnames doesn't match or there is some failure, we try to check remotely
+ if (!$found) {
+ $found = $this->checkUser($aCommand[2], $aCommand[1], true);
+ }
+
+ if ($found) {
+ // The user is okay
+ $this->writeLog(LOG_NOTICE, 'valid user: ' . $sUser);
+ fwrite(STDOUT, pack('nn', 2, 1));
+ } else {
+ // The user isn't okay
+ $this->writeLog(LOG_WARNING, 'invalid user: ' . $sUser);
+ fwrite(STDOUT, pack('nn', 2, 0));
+ }
+ }
+
+ /**
+ * @brief Check remote user existance via HTTP(S)
+ *
+ * @param string $host The hostname
+ * @param string $user Username
+ * @param boolean $ssl Should the check be done via SSL?
+ *
+ * @return boolean Was the user found?
+ */
+ private function checkUser($host, $user, $ssl)
+ {
+ $this->writeLog(LOG_INFO, 'external user check for ' . $user . '@' . $host);
+
+ $url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
+
+ $data = z_fetch_url($url);
+
+ if (!is_array($data)) {
+ return false;
+ }
+
+ if ($data['return_code'] != '200') {
+ return false;
+ }
+
+ $json = @json_decode($data['body']);
+ if (!is_object($json)) {
+ return false;
+ }
+
+ return $json->nick == $user;
+ }
+
+ /**
+ * @brief Authenticate the given user and password
+ *
+ * @param array $aCommand The command array
+ */
+ private function auth(array $aCommand)
+ {
+ $a = get_app();
+
+ // check user authentication
+ if (sizeof($aCommand) != 4) {
+ $this->writeLog(LOG_NOTICE, 'invalid auth command, data missing');
+ fwrite(STDOUT, pack('nn', 2, 0));
+ return;
+ }
+
+ // We now check if the password match
+ $sUser = str_replace(array('%20', '(a)'), array(' ', '@'), $aCommand[1]);
+
+ // Does the hostname match? So we try directly
+ if ($a->get_hostname() == $aCommand[2]) {
+ $this->writeLog(LOG_INFO, 'internal auth for ' . $sUser . '@' . $aCommand[2]);
+
+ $aUser = dba::select('user', ['uid', 'password'], ['nickname' => $sUser], ['limit' => 1]);
+ if (DBM::is_result($aUser)) {
+ $uid = $aUser['uid'];
+ $Error = $aUser['password'] != hash('whirlpool', $aCommand[3]);
+ } else {
+ $this->writeLog(LOG_WARNING, 'user not found: ' . $sUser);
+ $Error = true;
+ $uid = -1;
+ }
+ if ($Error) {
+ $this->writeLog(LOG_INFO, 'check against alternate password for ' . $sUser . '@' . $aCommand[2]);
+ $sPassword = PConfig::get($uid, 'xmpp', 'password', null, true);
+ $Error = ($aCommand[3] != $sPassword);
+ }
+ } else {
+ $Error = true;
+ }
+
+ // If the hostnames doesn't match or there is some failure, we try to check remotely
+ if ($Error) {
+ $Error = !$this->checkCredentials($aCommand[2], $aCommand[1], $aCommand[3], true);
+ }
+
+ if ($Error) {
+ $this->writeLog(LOG_WARNING, 'authentification failed for user ' . $sUser . '@' . $aCommand[2]);
+ fwrite(STDOUT, pack('nn', 2, 0));
+ } else {
+ $this->writeLog(LOG_NOTICE, 'authentificated user ' . $sUser . '@' . $aCommand[2]);
+ fwrite(STDOUT, pack('nn', 2, 1));
+ }
+ }
+
+ /**
+ * @brief Check remote credentials via HTTP(S)
+ *
+ * @param string $host The hostname
+ * @param string $user Username
+ * @param string $password Password
+ * @param boolean $ssl Should the check be done via SSL?
+ *
+ * @return boolean Are the credentials okay?
+ */
+ private function checkCredentials($host, $user, $password, $ssl)
+ {
+ $url = ($ssl ? 'https' : 'http') . '://' . $host . '/api/account/verify_credentials.json';
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_HEADER, true);
+ curl_setopt($ch, CURLOPT_NOBODY, true);
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ curl_setopt($ch, CURLOPT_USERPWD, $user . ':' . $password);
+
+ curl_exec($ch);
+ $curl_info = @curl_getinfo($ch);
+ $http_code = $curl_info['http_code'];
+ curl_close($ch);
+
+ $this->writeLog(LOG_INFO, 'external auth for ' . $user . '@' . $host . ' returned ' . $http_code);
+
+ return $http_code == 200;
+ }
+
+ /**
+ * @brief write data to the syslog
+ *
+ * @param integer $loglevel The syslog loglevel
+ * @param string $sMessage The syslog message
+ */
+ private function writeLog($loglevel, $sMessage)
+ {
+ if (!$this->bDebug && ($loglevel >= LOG_DEBUG)) {
+ return;
+ }
+ syslog($loglevel, $sMessage);
+ }
+
+ /**
+ * @brief destroy the class, close the syslog connection.
+ */
+ public function __destruct()
+ {
+ $this->writeLog(LOG_NOTICE, 'stop');
+ closelog();
+ }
+}
diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php
index 08a1af6dc..cbfa86ed8 100644
--- a/src/Worker/CronJobs.php
+++ b/src/Worker/CronJobs.php
@@ -155,14 +155,15 @@ class CronJobs {
if (!$cachetime) {
$cachetime = PROXY_DEFAULT_TIME;
}
- q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
+ $condition = array('`uid` = 0 AND `resource-id` LIKE "pic:%" AND `created` < NOW() - INTERVAL ? SECOND', $cachetime);
+ dba::delete('photo', $condition);
}
- // Delete the cached OEmbed entries that are older than one year
- q("DELETE FROM `oembed` WHERE `created` < NOW() - INTERVAL 3 MONTH");
+ // Delete the cached OEmbed entries that are older than three month
+ dba::delete('oembed', array("`created` < NOW() - INTERVAL 3 MONTH"));
- // Delete the cached "parse_url" entries that are older than one year
- q("DELETE FROM `parsed_url` WHERE `created` < NOW() - INTERVAL 3 MONTH");
+ // Delete the cached "parse_url" entries that are older than three month
+ dba::delete('parsed_url', array("`created` < NOW() - INTERVAL 3 MONTH"));
// Maximum table size in megabyte
$max_tablesize = intval(Config::get('system','optimize_max_tablesize')) * 1000000;
diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php
index 14fe3027f..216d2520d 100644
--- a/src/Worker/Delivery.php
+++ b/src/Worker/Delivery.php
@@ -485,7 +485,7 @@ class Delivery {
break;
if ($mail) {
- Diaspora::send_mail($item,$owner,$contact);
+ Diaspora::sendMail($item,$owner,$contact);
break;
}
@@ -498,7 +498,7 @@ class Delivery {
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
// top-level retraction
logger('diaspora retract: '.$loc);
- Diaspora::send_retraction($target_item,$owner,$contact,$public_message);
+ Diaspora::sendRetraction($target_item,$owner,$contact,$public_message);
break;
} elseif ($relocate) {
Diaspora::sendAccountMigration($owner, $contact, $uid);
@@ -506,17 +506,17 @@ class Delivery {
} elseif ($followup) {
// send comments and likes to owner to relay
logger('diaspora followup: '.$loc);
- Diaspora::send_followup($target_item,$owner,$contact,$public_message);
+ Diaspora::sendFollowup($target_item,$owner,$contact,$public_message);
break;
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
// we are the relay - send comments, likes and relayable_retractions to our conversants
logger('diaspora relay: '.$loc);
- Diaspora::send_relay($target_item,$owner,$contact,$public_message);
+ Diaspora::sendRelay($target_item,$owner,$contact,$public_message);
break;
} elseif ($top_level && !$walltowall) {
// currently no workable solution for sending walltowall
logger('diaspora status: '.$loc);
- Diaspora::send_status($target_item,$owner,$contact,$public_message);
+ Diaspora::sendStatus($target_item,$owner,$contact,$public_message);
break;
}
diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php
index f3096e41a..ac8cf123c 100644
--- a/src/Worker/Notifier.php
+++ b/src/Worker/Notifier.php
@@ -525,7 +525,7 @@ class Notifier {
if ($diaspora_delivery) {
if (!$followup) {
- $r0 = Diaspora::relay_list();
+ $r0 = Diaspora::relayList();
}
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php
index 43c76965d..e33aa5d9a 100644
--- a/src/Worker/ProfileUpdate.php
+++ b/src/Worker/ProfileUpdate.php
@@ -14,6 +14,6 @@ class ProfileUpdate {
return;
}
- Diaspora::send_profile($uid);
+ Diaspora::sendProfile($uid);
}
}
diff --git a/util/bookmarklet-share2friendica/README.md b/util/bookmarklet-share2friendica/README.md
new file mode 100644
index 000000000..ad30baa9d
--- /dev/null
+++ b/util/bookmarklet-share2friendica/README.md
@@ -0,0 +1,47 @@
+# Bookmarklet-share2friendica
+
+Javascript bookmarklet to share websites with your friendica account
+
+## Getting Started
+
+### Installing
+
+Open the file bookmarklet-share2friendica.js and change 'YourFriendicaDoomain.tld" with your friendica domain
+
+If you friendica is at https://myfriend.myfami.ly/ , the original ...
+```javascript
+javascript:(function(){f='https://YourFriendicaDomain.tld/bookmarklet/?url='+encodeURIC....
+```
+... has to be changed to ...
+
+```javascript
+javascript:(function(){f='https://myfriend.myfami.ly/bookmarklet/?url='+encodeURIC....
+```
+
+*Please copy the whole script, not only the part mentioned here!*
+
+Then create a new bookmark, give it a name like "share2Friendica" and paste the script in the address field. Save it. Now you can click on that bookmarklet every time you want to share a website, you are currently reading. A new small window will open where title is prefilled and the website you want to share is put as attachement in the body of the new post.
+
+## Additional notes if it doesn't work
+
+* Make sure the site you want to share is allowed to run javascript. (enable it in your script blocker)
+* Check the apostrophes that are used. Sometimes it is changed by the copy and paste process depending on the editor you are using, or if you copy it from a website. Correct it and it will work again.
+
+
+
+## Authors
+
+* **diaspora** - *Initial work* - [Share all teh internetz!](https://share.diasporafoundation.org/about.html)
+* **hoergen** - *Adaptation to Friendica (2017)* - [hoergen.org](https://hoergen.org)
+
+## License
+
+This project is licensed under the same license like friendica
+
+## Acknowledgments
+
+* Hat tip to anyone who's code was used
+* Hat tip to everyone who does everyday a little something ot make this world better
+* Had tip but spent it
+
+
diff --git a/util/bookmarklet-share2friendica/bookmarklet-share2friendica.js b/util/bookmarklet-share2friendica/bookmarklet-share2friendica.js
new file mode 100644
index 000000000..584dee240
--- /dev/null
+++ b/util/bookmarklet-share2friendica/bookmarklet-share2friendica.js
@@ -0,0 +1 @@
+javascript:(function(){f='https://YourFriendicaDomain.tld/bookmarklet/?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title);a=function(){if(!window.open(f+'&jump=doclose','friendica','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
diff --git a/util/global_community_block.php b/util/global_community_block.php
new file mode 100755
index 000000000..cb6789e45
--- /dev/null
+++ b/util/global_community_block.php
@@ -0,0 +1,65 @@
+#!/usr/bin/env php
+ util/global_community_block.php http://example.com/profile/bob
+ *
+ * will block bob@example.com.
+ *
+ * Author: Tobias Diekershoff
+ *
+ * License: AGPLv3 or later, same as Friendica
+ **/
+
+if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
+ echo "Usage: ".$argv[0]." [-h|profile_url]\r\n";
+ echo " -h, -?, --help ... show this help\r\n";
+ echo " profile_url ...... The URL of the profile you want to silence\r\n";
+ echo "\r\n";
+ echo "Example: block bob@example.com\r\n";
+ echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
+ echo "\r\n";
+ exit(0);
+}
+
+use Friendica\Database\DBM;
+use Friendica\Network\Probe;
+
+require_once 'boot.php';
+require_once 'include/dba.php';
+require_once 'include/text.php';
+$a = get_app();
+require_once '.htconfig.php';
+
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
+
+/**
+ * 1. make nurl from last parameter
+ * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
+ * 3. set the flag hidden=1 for the contact entry with the found ID
+ **/
+$net = Probe::uri($argv[1]);
+if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
+ echo 'This account seems not to exist.';
+ echo "\r\n";
+ exit(1);
+}
+$nurl = normalise_link($net['url']);
+$r = dba::select('contact', array('id'), array('nurl' => $nurl, 'uid' => 0), array('limit' => 1));
+if (DBM::is_result($r)) {
+ dba::update('contact', array('blocked' => true), array('id' => $r['id']));
+ echo "NOTICE: The account should be blocked from the node now\r\n";
+} else {
+ echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";
+}
+
+?>
diff --git a/util/global_community_silence.php b/util/global_community_silence.php
new file mode 100755
index 000000000..e6c936f0d
--- /dev/null
+++ b/util/global_community_silence.php
@@ -0,0 +1,68 @@
+#!/usr/bin/env php
+ util/global_community_silence.php http://example.com/profile/bob
+ *
+ * will silence bob@example.com so that his postings won't appear at
+ * the global community page.
+ *
+ * Author: Tobias Diekershoff
+ *
+ * License: AGPLv3 or later, same as Friendica
+ **/
+
+if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
+ echo "Usage: ".$argv[0]." [-h|profile_url]\r\n";
+ echo " -h, -?, --help ... show this help\r\n";
+ echo " profile_url ...... The URL of the profile you want to silence\r\n";
+ echo "\r\n";
+ echo "Example: Silence bob@example.com\r\n";
+ echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
+ echo "\r\n";
+ exit(0);
+}
+
+use Friendica\Database\DBM;
+use Friendica\Network\Probe;
+
+require_once 'boot.php';
+require_once 'include/dba.php';
+require_once 'include/text.php';
+$a = get_app();
+require_once '.htconfig.php';
+
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
+
+/**
+ * 1. make nurl from last parameter
+ * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
+ * 3. set the flag hidden=1 for the contact entry with the found ID
+ **/
+$net = Probe::uri($argv[1]);
+if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
+ echo "This account seems not to exist.";
+ echo "\r\n";
+ exit(1);
+}
+$nurl = normalise_link($net['url']);
+$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit" => 1));
+if (DBM::is_result($r)) {
+ dba::update("contact", array("hidden" => true), array("id" => $r["id"]));
+ echo "NOTICE: The account should be silenced from the global community page\r\n";
+} else {
+ echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";
+}
+
+?>
diff --git a/view/templates/contact_edit.tpl b/view/templates/contact_edit.tpl
index bad1b63c3..449316189 100644
--- a/view/templates/contact_edit.tpl
+++ b/view/templates/contact_edit.tpl
@@ -1,4 +1,3 @@
-
{{* Insert Tab-Nav *}}
@@ -71,7 +70,7 @@
{{include file="field_checkbox.tpl" field=$notify}}
{{if $fetch_further_information}}
{{include file="field_select.tpl" field=$fetch_further_information}}
- {{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+ {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
{{/if}}
{{include file="field_checkbox.tpl" field=$hidden}}
diff --git a/view/theme/frio/templates/contact_edit.tpl b/view/theme/frio/templates/contact_edit.tpl
index 540aebef5..52f3fc545 100644
--- a/view/theme/frio/templates/contact_edit.tpl
+++ b/view/theme/frio/templates/contact_edit.tpl
@@ -134,7 +134,7 @@
{{include file="field_checkbox.tpl" field=$notify}}
{{if $fetch_further_information}}
{{include file="field_select.tpl" field=$fetch_further_information}}
- {{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+ {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
{{/if}}
{{include file="field_checkbox.tpl" field=$hidden}}
diff --git a/view/theme/vier/templates/contact_edit.tpl b/view/theme/vier/templates/contact_edit.tpl
index f4f85d611..9dc11a31c 100644
--- a/view/theme/vier/templates/contact_edit.tpl
+++ b/view/theme/vier/templates/contact_edit.tpl
@@ -71,7 +71,7 @@
{{include file="field_checkbox.tpl" field=$notify}}
{{if $fetch_further_information}}
{{include file="field_select.tpl" field=$fetch_further_information}}
- {{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+ {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
{{/if}}
{{include file="field_checkbox.tpl" field=$hidden}}