]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #4193 from annando/item-unification
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 10 Jan 2018 14:11:36 +0000 (09:11 -0500)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2018 14:11:36 +0000 (09:11 -0500)
We now are using a single function to store items

35 files changed:
doc/Developers-Intro.md
doc/FAQ.md
doc/SSL.md
doc/database/db_gserver.md
doc/de/FAQ.md
doc/de/SSL.md
include/acl_selectors.php
include/api.php
include/contact_selectors.php [deleted file]
include/contact_widgets.php
include/conversation.php
include/follow.php [deleted file]
include/text.php
mod/allfriends.php
mod/common.php
mod/contacts.php
mod/crepair.php
mod/dirfind.php
mod/follow.php
mod/fsuggest.php
mod/nogroup.php
mod/notifications.php
mod/ostatus_subscribe.php
mod/repair_ostatus.php
mod/salmon.php
mod/suggest.php
mod/unfollow.php
mod/viewcontacts.php
ruleset.xml [new file with mode: 0644]
src/Content/ContactSelector.php [new file with mode: 0644]
src/Model/Contact.php
src/Object/Post.php
src/Protocol/OStatus.php
src/Worker/OnePoll.php
vendor/pear/text_languagedetect/phpcs.xml

index 044599435bb728ae5f7c54438e5f47216e92e5a4..c9aef17754a72a086ffa47f2dd31958cb5aeb2d4 100644 (file)
@@ -76,7 +76,7 @@ This tool checks your files against a variety of coding standards, including PSR
 You can simply install it through PEAR: `pear install PHP_CodeSniffer`
 Once it is installed and available in your PATH, here's the command to run before committing your work:
 
-       $> phpcs --standard=PSR2 <file or directory>
+       $> phpcs --standard=ruleset.xml <file or directory>
 
 The output is a list of all the coding standards violations that you should fix before committing your work.
 Additionally, `phpcs` integrates with a few IDEs (Eclipse, Netbeans, PHPStorm...) so that you don't have to fiddle with the command line.
@@ -87,7 +87,7 @@ If you're getting a massive list of standards violations when running `phpcs`, i
 Thankfully, PHP Code Sniffer is shipped with an automatic code fixer that can take care of the tedious task for you.
 Here's the command to automatically fix the files you created/modified:
 
-       $> phpcbf --standard=PSR2 <file or directory>
+       $> phpcbf --standard=ruleset.xml <file or directory>
 
 If the command-line tools `diff` and `patch` are unavailabe for you, `phpcbf` can use slightly slower PHP equivalents by using the `--no-patch` argument.
 
index 32c5f74cdc020f967948acb724ca9a164c427f50..fddc64abc048dc1a726ec2562614bc4005658795 100644 (file)
@@ -21,12 +21,11 @@ Admins
 * **[Where can I find the source code of friendica, addons and themes?](help/FAQ#sources)**
 * **[I've changed the my email address now the admin panel is gone?](help/FAQ#adminaccount1)**
 * **[Can there be more then just one admin for a node?](help/FAQ#adminaccount2)**
+* **[The Database structure seems not to be updated. What can I do?](help/FAQ#dbupdate)**
 
 User
 --------
-*****
 <a name="ssl"></a>
-
 ### Why do I get warnings about SSL certificates?
 
 SSL (Secure Socket Layer) is a technology to encrypt data transfer between computers.
@@ -40,7 +39,6 @@ These warnings can have three reasons:
 We recommend to talk to the admin(s) of the affected friendica server. (Admins, please see the respective section of the [admin manual](help/SSL).)
 
 <a name="upload"></a>
-
 ### How can I upload images, files, links, videos and sound files to posts?
 
 You can upload images from your computer using the [editor](help/Text_editor).
@@ -70,7 +68,6 @@ Some supported filetypes are WebM, MP4, MP3 and OGG.
 See Wikipedia for more of them ([video](http://en.wikipedia.org/wiki/HTML5_video), [audio](http://en.wikipedia.org/wiki/HTML5_audio)).
 
 <a name="avatars"></a>
-
 ### Is it possible to have different avatars per profile?
 
 Yes. On your Edit/Manage Profiles page, you will find a "change profile photo" link.
@@ -78,7 +75,6 @@ Clicking this will take you to a page where you can upload a photograph and sele
 To avoid privacy leakage, we only display the photograph associated with your default profile as the avatar in your posts.
 
 <a name="contacts"></a>
-
 ### What is the difference between blocked|ignored|archived|hidden contacts?
 
 We prevent direct communication with **blocked contacts**.
@@ -101,7 +97,6 @@ A **hidden contact** will not be displayed in any "friend list" (except to you).
 However a hidden contact will appear normally in conversations and this may expose his/her hidden status to anybody who can see the conversation.
 
 <a name="removed"></a>
-
 ### What happens when an account is removed? Is it truly deleted?
 
 If you delete your account, we will immediately remove all your content on **your** server.
@@ -114,7 +109,6 @@ We can block it in several ways so that it appears empty and all profile informa
 After that, your account is deleted.
 
 <a name="hashtag"></a>
-
 ### Can I follow a hashtag?
 
 No. The act of 'following' a hashtags is an interesting technology, but presents a few issues.
@@ -128,29 +122,27 @@ No. The act of 'following' a hashtags is an interesting technology, but presents
 Instead, we offer other mechanisms for wide-area conversations while retaining a 'level playing ground' for both large and small sites, such as forums and community pages and shared tags.
 
 <a name="rss"></a>
-
 ### How to create a RSS feed of the stream?
 
 If you want to share your public page via rss you can use one of the following links:
 
-RSS feed of your posts
+#### RSS feed of your posts
 
-       basic-url.com/**dfrn_poll/profilename  
+       basic-url.com//feed/[nickname]/posts
 
-       Example: Friendica Support 
+Example: Friendica Support 
        
-       https://forum.friendi.ca/dfrn_poll/helpers
+       https://forum.friendi.ca/feed/helpers/posts
 
-RSS feed of the conversations at your site
+#### RSS feed of the conversations at your site
 
-       basic-url.com/dfrn_poll/profilename/converse
+       basic-url.com/feed/profilename/comments
        
-       Example: Friendica Support 
+Example: Friendica Support 
        
-       https://forum.friendi.ca/dfrn_poll/helpers/converse
+       https://forum.friendi.ca/feed/helpers/comments
 
 <a name="clients"></a>
-
 ### Are there any clients for friendica I can use?
 
 Friendica is using a [Twitter/GNU Social compatible API](help/api), which means you can use any Twitter/GNU Social client for your plattform as long as you can change the API path in its settings.
@@ -186,15 +178,13 @@ If you are a theme developer, you will find help at this forum: [Friendica Theme
 
 Admin
 --------
-*****
-<a name="multiple"></a>
 
+<a name="multiple"></a>
 ### Can I configure multiple domains with the same code instance?
 
 No, this function is no longer supported as of Friendica 3.3 onwards.
 
 <a name="sources"></a>
-
 ### Where can I find the source code of friendica, addons and themes?
 
 You can find the main respository [here](https://github.com/friendica/friendica).
@@ -212,5 +202,19 @@ Have a look into your <tt>.htconfig.php</tt> and fix your email address there.
 <a name="adminaccount2"></a>
 ### Can there be more then one admin for a node?
 
-Yes. You just have to list more then one email address in the
-<tt>.htconfig.php</tt> file. The listed emails need to be separated by a comma.
+Yes.
+You just have to list more then one email address in the
+<tt>.htconfig.php</tt> file.
+The listed emails need to be separated by a comma.
+
+<a name="dbupdate">
+### The Database structure seems not to be updated. What can I do?
+
+Please have a look at the Admin panel under [DB updates](/admin/dbsync/) and follow the link to *check database structure*.
+This will start a background process to check if the structure is up to the current definition.
+
+You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following script:
+
+    scripts/dbstructure.php update
+
+if there occur any errors, please contact the [support forum](https://forum.friendi.ca/profile/helpers).
index 9d2bee775681ede587dc54d683d6e2fa149707d1..90ff1e59184e540c94facd2b673d25ff76b074e7 100644 (file)
@@ -71,7 +71,7 @@ Every time a user tries to access any Friendica page by any mean (manual address
 
 With Apache, enable the modules rewrite and ssl (with a shared hosting provider, this should be enabled already):
 
-       sudo a2enmod rewrite ssl
+        sudo a2enmod rewrite ssl
 
 Add the following lines to the .htaccess file in the root folder of your Friendica instance (thanks to [url=https://github.com/AlfredSK]AlfredSK[/url]):
 
index 4b2107fc55a9bc276f2f9ab27643ec22c74fe33c..d9ec69a53cb0509ebe36bb22f2b09823e8382b04 100644 (file)
@@ -1,23 +1,24 @@
 Table gserver
 =============
 
-| Field           | Description      | Type             | Null | Key | Default             | Extra          |
-|-----------------|------------------|------------------|------|-----|---------------------|----------------|
-| id              | sequential ID    | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
-| url             |                  | varchar(255)     | NO   |     |                     |                |
-| nurl            |                  | varchar(255)     | NO   | MUL |                     |                |
-| version         |                  | varchar(255)     | NO   |     |                     |                |
-| site_name       |                  | varchar(255)     | NO   |     |                     |                |
-| info            |                  | text             | NO   |     | NULL                |                |
-| register_policy |                  | tinyint(1)       | NO   |     | 0                   |                |
-| poco            |                  | varchar(255)     | NO   |     |                     |                |
-| noscrape        |                  | varchar(255)     | NO   |     |                     |                |
-| network         |                  | varchar(32)      | NO   |     |                     |                |
-| platform        |                  | varchar(255)     | NO   |     |                     |                |
-| created         |                  | datetime         | NO   |     | 0001-01-01 00:00:00 |                |
-| last_poco_query |                  | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
-| last_contact    |                  | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
-| last_failure    |                  | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
+| Field            | Description               | Type             | Null | Key | Default             | Extra          |
+|------------------|---------------------------|------------------|------|-----|---------------------|----------------|
+| id               | sequential ID             | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
+| url              |                           | varchar(255)     | NO   |     |                     |                |
+| nurl             |                           | varchar(255)     | NO   | MUL |                     |                |
+| version          |                           | varchar(255)     | NO   |     |                     |                |
+| site_name        |                           | varchar(255)     | NO   |     |                     |                |
+| info             |                           | text             | NO   |     | NULL                |                |
+| register_policy  |                           | tinyint(1)       | NO   |     | 0                   |                |
+| registered-users |Number of registered users | int(10)          | NO   |     | 0                   |                |
+| poco             |                           | varchar(255)     | NO   |     |                     |                |
+| noscrape         |                           | varchar(255)     | NO   |     |                     |                |
+| network          |                           | varchar(32)      | NO   |     |                     |                |
+| platform         |                           | varchar(255)     | NO   |     |                     |                |
+| created          |                           | datetime         | NO   |     | 0001-01-01 00:00:00 |                |
+| last_poco_query  |                           | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
+| last_contact     |                           | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
+| last_failure     |                           | datetime         | YES  |     | 0001-01-01 00:00:00 |                |
 
 
 Return to [database documentation](help/database)
index 2464ec1e0765a73718378059a8897fb40f50023b..e78e8bc21aea225a0337b3c05db641ab053ebc09 100644 (file)
@@ -19,13 +19,15 @@ Admins
 
 * **[Kann ich mehrere Domains mit den selben Dateien aufsetzen?](help/FAQ#multiple)**
 * **[Wo kann ich den Quellcode von Friendica, Addons und Themes finden?](help/FAQ#sources)**
+* **[Ich habe meine E-Mail Adresse geändern und jetzt ist das Admin Panel verschwunden?](help/FAQ#adminaccount1)**
+* **[Kann es mehr als einen Admin auf einer Friendica Instanz geben?](help/FAQ#adminaccount2)**
+* **[Die Datenbank Struktur schein nicht aktuell zu sein. Was kann ich tun?](help/FAQ#dbupdate)**
 
 Nutzer
 --------
-****
-<a name="ssl"></a>
 
-**Warum erhalte ich Warnungen Ã¼ber fehlende Zertifikate?**
+<a name="ssl"></a>
+### Warum erhalte ich Warnungen Ã¼ber fehlende Zertifikate?
 
 Manchmal erhältst Du eine Browser-Warnung Ã¼ber fehlende Zertifikate. 
 Diese Warnungen können drei Gründe haben:
@@ -55,8 +57,7 @@ Einige erlauben die Nutzung von freien Zertifikaten oder lassen Dich ihre eigene
 Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern. 
 
 <a name="upload"></a>
-
-**Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?**
+### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
 
 Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden. 
 Eine Ãœbersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>. 
@@ -81,8 +82,7 @@ Friendica verwendet zur Einbettung HTML5. Das bedeutet, dass je nach Browser und
 Zum Konvertieren von Videos in das lizenfreie Videoformat WebM gibt es unter Windows das kostenlose Programm [Xmedia-Recode](http://www.xmedia-recode.de/).
 
 <a name="avatars"></a>
-
-**Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?**
+### Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?
 
 Ja. 
 Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus. 
@@ -91,8 +91,7 @@ Klicke nun oben auf den Link "Profilbild Ã¤ndern" und lade im nächsten Fenster
 Um Deine privaten Daten zu schützen, wird in Beiträgen nur das Bild aus Deinem Ã¶ffentlichen Profil angezeigt.
 
 <a name="contacts"></a>
-
-**Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?**
+### Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?
 
 Wir verhindern direkte Kommunikation mit blockierten Kontakten. 
 Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert. 
@@ -115,8 +114,7 @@ Ein versteckter Kontakt wird in keiner "Freundeliste" erscheinen (außer für di
 Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist. 
 
 <a name="removed"></a>
-
-**Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?**
+### Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?
 
 Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt. 
 Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht. 
@@ -124,8 +122,7 @@ Dieses Vorgehen setzt voraus, dass Dein Profil für 24 Stunden weiterhin "teilwe
 Wir können also Dein Profil blockieren und es so erscheinen lassen, als wären alle Daten sofort gelöscht, allerdings warten wir 24 Stunden (bzw. bis alle Deine Kontakte informiert wurden), bevor wir die Daten auch physikalisch löschen.
 
 <a name="hashtag"></a>
-
-**Kann ich einem hashtag folgen?**
+### Kann ich einem hashtag folgen?
 
 Nein. 
 Die Möglichkeit, einem hashtag zu folgen, ist eine interessante Technik, führt aber zu einigen Schwierigkeiten. 
@@ -140,29 +137,31 @@ Stattdessen bieten wir andere Mechanismen, um globale Unterhaltungen zu erreiche
 Hierzu gehören Foren, Gruppen und geteilte tags. 
 
 <a name="rss"></a>
-
-**Wie kann ich einen RSS-Feed meiner Netzwerkseite (Stream) erstellen?**
+### Wie kann ich einen RSS-Feed meiner Netzwerkseite (Stream) erstellen?
 
 Wenn Du die Beiträge Deines Accounts mit RSS teilen willst, dann kannst Du einen der folgenden Links nutzen:
 
-RSS-Feed Deiner Beiträge
+#### RSS-Feed Deiner Beiträge
 
-       deineSeite.de/**dfrn_poll/profilname  
+       deineSeite.de/feed/[profilname]/posts
 
-       Beispiel: Friendica Support 
+Beispiel: Friendica Support 
        
-       https://forum.friendi.ca/dfrn_poll/helpers
+       https://forum.friendi.ca/feed/helpers/posts
 
-RSS-Feed aller Unterhaltungen auf Deiner Seite
+#### RSS-Feed all deiner Beiträge und Antworten
 
-       deineSeite.de/dfrn_poll/profilname/converse
+    deineSeite.de/dfrn_poll/feed/[profilname]/comments
        
-       Beispiel: Friendica Support 
+Beispiel: Friendica Support 
        
-       https://forum.friendi.ca/dfrn_poll/helpers/converse
+    https://forum.friendi.ca/feeds/helpers/comments
 
-<a name="clients">
+#### RSS-Feed all deiner Aktivitäten
 
+    deineSeite.de/feed/[profilname]/
+
+<a name="clients">
 ### Gibt es Clients für Friendica?
 
 Friendica verwendet eine [Twitter/GNU Social](help/api) kompatible API.
@@ -187,8 +186,7 @@ Hier ist eine Liste von Clients bei denen dies möglich ist, bzw. die speziell f
   * Hotot
 
 <a name="help"></a>
-
-**Wo finde ich Hilfe?**
+### Wo finde ich Hilfe?
 
 Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen. 
 Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer Ã¶ffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen, oder Du wählst die Librelist-mailing-Liste. 
@@ -198,10 +196,9 @@ Wenn Du ein Theme-Entwickler bist, wirst Du in diesem Forum Hilfe finden: [Frien
 
 Admin
 --------
-*****
-<a name="multiple"></a>
 
-**Kann ich mehrere Domains mit den selben Dateien aufsetzen?**
+<a name="multiple"></a>
+### Kann ich mehrere Domains mit den selben Dateien aufsetzen?
 
 Ja, das ist möglich. 
 Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen. 
@@ -209,8 +206,7 @@ Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht
 Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
 
 <a name="sources"></a>
-
-**Wo kann ich den Quellcode von Friendica, Addons und Themes finden?**
+### Wo kann ich den Quellcode von Friendica, Addons und Themes finden?
 
 Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden. 
 Dort findest Du immer die aktuellste stabile Version von Friendica. 
@@ -219,3 +215,28 @@ Der Quellcode von Friendica Red ist [hier](https://github.com/friendica/red) zu
 Addons findest Du auf [dieser Seite](https://github.com/friendica/friendica-addons).
 
 Wenn Du neue Themen suchst, findest Du sie auf [Friendica-Themes.com](http://friendica-themes.com/).
+
+<a name="adminaccount1"></a>
+### Ich habe meine E-Mail Adresse geändern und jetzt ist das Admin Panel verschwunden?
+
+Bitte aktualisiere deine E-Mail Adresse in der <tt>.htconfig.php</tt> Datei.
+
+<a name="adminaccount2"></a>
+### Kann es mehr als einen Admin auf einer Friendica Instanz geben?
+
+Ja.
+Du kannst in der <tt>.htconfig.php</tt> Datei mehrere E-Mail Adressen auflisten.
+Die aufgelisteten Adressen werden mit Kommata von einander getrennt.
+
+<a name="dbupdate">
+### Die Datenbank Struktur schein nicht aktuell zu sein. Was kann ich tun?
+
+Rufe bitte im Admin Panel den Punkt [DB Updates](/admin/dbsync/) auf und folge dem Link *Datenbank Struktur Ã¼berprüfen*.
+Damit wird ein Hintergrundprozess gestartet der die Struktur deiner Datenbank Ã¼berprüft und gegebenenfalls aktualisiert.
+
+Du kannst das Struktur Updatee auch manuell auf der Kommandoeingabe ausführen.
+Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Skript:
+
+    scripts/dbstructure.php update
+
+sollten bei der Ausführung Fehler auftreten, kontaktiere bitte das [Support Forum](https://forum.friendi.ca/profile/helpers).
index d1929120a46b812191f2082e9b78cd3815b54260..3d20cb5b1e9c8b6bd3e6231be1bf24e13729ee7b 100644 (file)
@@ -3,15 +3,14 @@ Friendica mit SSL nutzen
 
 * [Zur Startseite der Hilfe](help)
 
-Disclaimer
----
+## Disclaimer
+
 **Dieses Dokument wurde im November 2016 aktualisiert.
 SSL-Verschlüsselung ist sicherheitskritisch.
 Das bedeutet, dass sich die empfohlenen Einstellungen schnell verändern.
 Halte deine Installation auf dem aktuellen Stand und verlasse dich nicht darauf, dass dieses Dokument genau so schnell aktualisiert wird, wie sich Technologien verändern!**
 
-Einleitung
----
+## Einleitung
 
 Wenn du deine eigene Friendica-Seite betreibst, willst du vielleicht SSL (https) nutzen, um die Kommunikation zwischen den Servern und zwischen dir und deinem Server zu verschlüsseln.
 
@@ -27,15 +26,13 @@ Normalerweise kosten sie Geld - und sind nur für eine begrenzte Zeit gültig (z
 
 Es gibt aber Möglichkeiten, ein vertrauenswürdiges Zertifikat umsonst zu bekommen.
 
-Wähle deinen Domainnamen
----
+## Wähle deinen Domainnamen
 
 Dein SSL-Zertifikat wird für eine bestimmte Domain gültig sein oder sogar nur für eine Subdomain.
 Entscheide dich endgültig für einen Domainnamen, *bevor* du ein Zertifikat bestellst.
 Wenn du das Zertifikat hast, brauchst du ein neues, wenn du den Domainnamen Ã¤ndern möchtest.
 
-Gehosteter Webspace
----
+## Gehosteter Webspace
 
 Wenn deine Friendica-Instanz auf einem gehosteten Webspace läuft, solltest du dich bei deinem Hosting-Provider informieren.
 Dort bekommst du Instruktionen, wie es dort läuft.
@@ -46,8 +43,7 @@ Um Geld zu sparen, kann es sich lohnen, dort auch nachzufragen, ob sie ein ander
 Wenn ja, dann lies weiter.
 
 
-Let's encrypt
----
+## Let's encrypt
 
 Wenn du einen eigenen Server betreibst und den Nameserver kontrollierst, könnte auch die Initiative "Let's encrypt" interessant für dich werden.
 Sie bietet nicht nur freie SSL Zertifikate sondern auch einen automatisierten Prozess zum Erneuern der Zertifikate.
@@ -55,32 +51,48 @@ Um letsencrypt Zertifikate verwenden zu können, musst du dir einen Client auf d
 Eine Anleitung zum offiziellen Client findet du [hier](https://certbot.eff.org/).
 Falls du dir andere Clients anschauen willst, kannst du einen Blick in diese [Liste von alternativen letsencrypt Clients](https://letsencrypt.org/docs/client-options/).
 
-Webserver-Einstellungen
----
+## Webserver-Einstellungen
 
 Im [Wiki von Mozilla](https://wiki.mozilla.org/Security/Server_Side_TLS) gibt es Anleitungen für die Konfiguration sicherer Webserver.
 Dort findest du Empfehlungen, die auf [verschiedene Webserver](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_Server_Configurations) zugeschnitten sind.
 
-Teste deine SSL-Einstellungen
----
+## Teste deine SSL-Einstellungen
 
 Wenn du fertig bist, kannst du auf der Testseite [SSL-Labs](https://www.ssllabs.com/ssltest/) prüfen lassen, ob Du alles richtig gemacht hast.
 
+## Friendica Konfigurieren
 
+Wenn du deine Friendica Instanz Ã¼ber https erreichen kannst solltest du ein paar Einstellungen vornehmen um sicher zu stellen, dass deine Nutzer ausschließlich Ã¼ber https zugreifen können.
 
+### Webserver-Umleitungen
 
+Dies ist der einfachste Weg den Zugriff für die ganze Webseite abzusichern.
+Jedes Mal wenn ein Nutzer Friendica aufruft wird er permanent vom Webserver auf die abgesicherte Seite umgeleitet.
 
+Wenn du den Apache Webserver verwendest, aktiviere die Module rewrite und ssl (bei einem Shared-Hosting Prider sollte dies bereits der Fall sein):
 
+        sudo a2enmod rewrite ssl
 
+und füge die folgenden Zeilen zur .htaccess Datei im Wurzelverzeichnis deiner Friendica Instanz hinzu:
 
+        RewriteEngine On
+        RewriteCond %{SERVER_PORT} 80
+        RewriteRule ^(.*)$ https://your.friendica.domain/$1 [R=301,L]
 
+(Dank an [url=https://github.com/AlfredSK]AlfredSK[/url]).
 
+Bei nginx solltest du deinen Server folgendermaßen konfigurieren ([documentation](https://www.nginx.com/blog/creating-nginx-rewrite-rules/)):
 
+        server {
+             listen 80;
+             server_name your.friendica.domain;
+             return 301 https://$server_name$request_uri;
+        }
 
+### SSL Einstellungen
 
+Im Admin-Panel gibt es drei Einstellungen, die SSL betreffen:
 
-
-
-
-
-
+1. **Regeln für SSL Links**: Diese Einstellung betrifft wie Friendica interne Links erzeugt. Wenn deine SSL Installation erfolgreich war, empfehlen wir die Einstellung "SSL für alle Links erzwingen".
+2. **Erzwinge SSL**: Mit dieser Einstellung werden alle externen Links auf HTTPS gesetzt. Dies kann bei Mixed-Content Problemen helfen, allerdings unterstützen noch nicht alle Webseiten HTTPS. Benutzung auf eigene Gefahr.
+3. **SSL Ã¼berprüfen**: Wenn diese Einstellung aktiv ist, wird Friendica nicht mehr mit Instanzen interagieren, die Ã¼ber ein selbst signiertes Zertifikat verfügen. Da selbst signierte Zertifikate ein Hinweis auf Man-in-the.Middle Angriffe sein können, empfehlen wir dies zu tun.
index 02ab95bb1efaff48d3d080afe604aaf9553cdffd..b71173e251cb916f198e8352d8de9bffa4865cb3 100644 (file)
@@ -9,7 +9,6 @@ use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 
-require_once "include/contact_selectors.php";
 require_once "include/contact_widgets.php";
 require_once "mod/proxy.php";
 
index e527cb003bb756b5bb94f4d0f8efae1bc020de50..bc60590a513799017ee7b379519899207796e2c7 100644 (file)
@@ -6,6 +6,7 @@
  * @todo Automatically detect if incoming data is HTML or BBCode
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\System;
 use Friendica\Core\Config;
@@ -38,7 +39,6 @@ require_once 'include/html2plain.php';
 require_once 'mod/share.php';
 require_once 'mod/item.php';
 require_once 'include/security.php';
-require_once 'include/contact_selectors.php';
 require_once 'include/html2bbcode.php';
 require_once 'mod/wall_upload.php';
 require_once 'mod/proxy.php';
@@ -610,7 +610,7 @@ function api_get_user(App $a, $contact_id = null)
                }
 
                if (DBM::is_result($r)) {
-                       $network_name = network_to_name($r[0]['network'], $r[0]['url']);
+                       $network_name = ContactSelector::networkToName($r[0]['network'], $r[0]['url']);
 
                        // If no nick where given, extract it from the address
                        if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
@@ -734,7 +734,7 @@ function api_get_user(App $a, $contact_id = null)
                $uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
        }
 
-       $network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
+       $network_name = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']);
 
        $pcontact_id  = Contact::getIdForURL($uinfo[0]['url'], 0, true);
 
@@ -1405,9 +1405,9 @@ function api_status_show($type)
                }
 
                if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
-                       $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
-               } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
-                       $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
+                       $status_info["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
+               } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
+                       $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['item_network'], $user_info['url']).')');
                }
 
                // "uid" and "self" are only needed for some internal stuff, so remove it from here
@@ -1496,11 +1496,11 @@ function api_users_show($type)
                }
 
                if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
-                       $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
+                       $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
                }
 
-               if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
-                       $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
+               if (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
+                       $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')');
                }
        }
 
@@ -3131,9 +3131,9 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
                }
 
                if (($item['item_network'] != "") && ($status["source"] == 'web')) {
-                       $status["source"] = network_to_name($item['item_network'], $user_info['url']);
-               } elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
-                       $status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')');
+                       $status["source"] = ContactSelector::networkToName($item['item_network'], $user_info['url']);
+               } elseif (($item['item_network'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) {
+                       $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')');
                }
 
 
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
deleted file mode 100644 (file)
index 67d05f3..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-use Friendica\Database\DBM;
-use Friendica\Protocol\Diaspora;
-
-function contact_profile_assign($current,$foreign_net) {
-
-       $o = '';
-
-       $disabled = (($foreign_net) ? ' disabled="true" ' : '');
-
-       $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
-
-       $r = q("SELECT `id`, `profile-name`, `is-default` FROM `profile` WHERE `uid` = %d",
-                       intval($_SESSION['uid']));
-
-       if (DBM::is_result($r)) {
-               foreach ($r as $rr) {
-                       $selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
-                       $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
-               }
-       }
-       $o .= "</select>\r\n";
-       return $o;
-}
-
-
-function contact_reputation($current) {
-
-       $o = '';
-       $o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
-
-       $rep = array(
-               0 => t('Unknown | Not categorised'),
-               1 => t('Block immediately'),
-               2 => t('Shady, spammer, self-marketer'),
-               3 => t('Known to me, but no opinion'),
-               4 => t('OK, probably harmless'),
-               5 => t('Reputable, has my trust')
-       );
-
-       foreach ($rep as $k => $v) {
-               $selected = (($k == $current) ? " selected=\"selected\" " : "");
-               $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
-       }
-       $o .= "</select>\r\n";
-       return $o;
-}
-
-
-function contact_poll_interval($current, $disabled = false) {
-
-       $dis = (($disabled) ? ' disabled="disabled" ' : '');
-       $o = '';
-       $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
-
-       $rep = array(
-               0 => t('Frequently'),
-               1 => t('Hourly'),
-               2 => t('Twice daily'),
-               3 => t('Daily'),
-               4 => t('Weekly'),
-               5 => t('Monthly')
-       );
-
-       foreach ($rep as $k => $v) {
-               $selected = (($k == $current) ? " selected=\"selected\" " : "");
-               $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
-       }
-       $o .= "</select>\r\n";
-       return $o;
-}
-
-
-function network_to_name($s, $profile = "") {
-
-       $nets = array(
-               NETWORK_DFRN     => t('Friendica'),
-               NETWORK_OSTATUS  => t('OStatus'),
-               NETWORK_FEED     => t('RSS/Atom'),
-               NETWORK_MAIL     => t('Email'),
-               NETWORK_DIASPORA => t('Diaspora'),
-               NETWORK_FACEBOOK => t('Facebook'),
-               NETWORK_ZOT      => t('Zot!'),
-               NETWORK_LINKEDIN => t('LinkedIn'),
-               NETWORK_XMPP     => t('XMPP/IM'),
-               NETWORK_MYSPACE  => t('MySpace'),
-               NETWORK_GPLUS    => t('Google+'),
-               NETWORK_PUMPIO   => t('pump.io'),
-               NETWORK_TWITTER  => t('Twitter'),
-               NETWORK_DIASPORA2 => t('Diaspora Connector'),
-               NETWORK_STATUSNET => t('GNU Social Connector'),
-               NETWORK_PNUT      => t('pnut'),
-               NETWORK_APPNET => t('App.net')
-       );
-
-       call_hooks('network_to_name', $nets);
-
-       $search  = array_keys($nets);
-       $replace = array_values($nets);
-
-       $networkname = str_replace($search, $replace, $s);
-
-       if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
-               $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
-                               INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
-                               WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
-
-               if (DBM::is_result($r)) {
-                       $networkname = $r['platform'];
-               }
-       }
-
-       return $networkname;
-}
index 55e119c3fa55617b27c64d69ce3f39d465e82c2e..a1c93f142b2aaf1297c292aaddf5fe1353ce3c31 100644 (file)
@@ -1,8 +1,8 @@
 <?php
-
 /**
  * @file include/contact_widgets.php
  */
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\System;
 use Friendica\Core\Config;
@@ -10,8 +10,6 @@ use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
 use Friendica\Model\GContact;
 
-require_once 'include/contact_selectors.php';
-
 function follow_widget($value = "")
 {
        return replace_macros(get_markup_template('follow.tpl'), array(
@@ -119,7 +117,7 @@ function networks_widget($baseurl, $selected = '')
        while ($rr = dba::fetch($r)) {
                /// @TODO If 'network' is not there, this triggers an E_NOTICE
                if ($rr['network']) {
-                       $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+                       $nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
                }
        }
        dba::close($r);
index 472896ffec2e45c3d342e8d11cd036bd1c2a8f05..423d9884e778a5b293746256ab5e1dbc8a28cbae 100644 (file)
@@ -3,6 +3,7 @@
  * @file include/conversation.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
@@ -776,7 +777,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                        'id' => (($preview) ? 'P0' : $item['item_id']),
                                        'guid' => (($preview) ? 'Q0' : $item['guid']),
                                        'network' => $item['item_network'],
-                                       'network_name' => network_to_name($item['item_network'], $profile_link),
+                                       'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link),
                                        'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
                                        'profile_url' => $profile_link,
                                        'item_photo_menu' => item_photo_menu($item),
diff --git a/include/follow.php b/include/follow.php
deleted file mode 100644 (file)
index 9aedafb..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-<?php
-
-/**
- * @file include/follow.php
- */
-use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\System;
-use Friendica\Core\Worker;
-use Friendica\Database\DBM;
-use Friendica\Model\Contact;
-use Friendica\Model\Group;
-use Friendica\Model\User;
-use Friendica\Network\Probe;
-use Friendica\Protocol\Diaspora;
-use Friendica\Protocol\OStatus;
-use Friendica\Protocol\PortableContact;
-use Friendica\Protocol\Salmon;
-
-function update_contact($id)
-{
-       /*
-         Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
-         This will reliably kill your communication with Friendica contacts.
-        */
-
-       $r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `network` FROM `contact` WHERE `id` = %d", intval($id));
-       if (!$r) {
-               return false;
-       }
-
-       $ret = Probe::uri($r[0]["url"]);
-
-       // If Probe::uri fails the network code will be different
-       if ($ret["network"] != $r[0]["network"]) {
-               return false;
-       }
-
-       $update = false;
-
-       // make sure to not overwrite existing values with blank entries
-       foreach ($ret AS $key => $val) {
-               if (isset($r[0][$key]) && ($r[0][$key] != "") && ($val == ""))
-                       $ret[$key] = $r[0][$key];
-
-               if (isset($r[0][$key]) && ($ret[$key] != $r[0][$key]))
-                       $update = true;
-       }
-
-       if (!$update) {
-               return true;
-       }
-
-       q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s' WHERE `id` = %d",
-               dbesc($ret['url']),
-               dbesc(normalise_link($ret['url'])),
-               dbesc($ret['addr']),
-               dbesc($ret['alias']),
-               dbesc($ret['batch']),
-               dbesc($ret['notify']),
-               dbesc($ret['poll']),
-               dbesc($ret['poco']),
-               intval($id)
-       );
-
-       // Update the corresponding gcontact entry
-       PortableContact::lastUpdated($ret["url"]);
-
-       return true;
-}
-
-/**
- * Takes a $uid and a url/handle and adds a new contact
- * Currently if the contact is DFRN, interactive needs to be true, to redirect to the
- * dfrn_request page.
- *
- * Otherwise this can be used to bulk add statusnet contacts, twitter contacts, etc.
- *
- * Returns an array
- * $return['success'] boolean true if successful
- * $return['message'] error text if success is false.
- *
- * @brief Takes a $uid and a url/handle and adds a new contact
- * @param int    $uid
- * @param string $url
- * @param bool   $interactive
- * @param string $network
- * @return boolean|string
- */
-function new_contact($uid, $url, $interactive = false, $network = '')
-{
-       $result = array('cid' => -1, 'success' => false, 'message' => '');
-
-       $a = get_app();
-
-       // remove ajax junk, e.g. Twitter
-       $url = str_replace('/#!/', '/', $url);
-
-       if (!allowed_url($url)) {
-               $result['message'] = t('Disallowed profile URL.');
-               return $result;
-       }
-
-       if (blocked_url($url)) {
-               $result['message'] = t('Blocked domain');
-               return $result;
-       }
-
-       if (!$url) {
-               $result['message'] = t('Connect URL missing.');
-               return $result;
-       }
-
-       $arr = array('url' => $url, 'contact' => array());
-
-       call_hooks('follow', $arr);
-
-       if (x($arr['contact'], 'name')) {
-               $ret = $arr['contact'];
-       } else {
-               $ret = Probe::uri($url, $network, $uid, false);
-       }
-
-       if (($network != '') && ($ret['network'] != $network)) {
-               logger('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
-               return result;
-       }
-
-       if ($ret['network'] === NETWORK_DFRN) {
-               if ($interactive) {
-                       if (strlen($a->path)) {
-                               $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
-                       } else {
-                               $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
-                       }
-
-                       goaway($ret['request'] . "&addr=$myaddr");
-
-                       // NOTREACHED
-               }
-       } elseif (Config::get('system', 'dfrn_only')) {
-               $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
-               $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
-               return $result;
-       }
-
-       // This extra param just confuses things, remove it
-       if ($ret['network'] === NETWORK_DIASPORA) {
-               $ret['url'] = str_replace('?absolute=true', '', $ret['url']);
-       }
-
-       // do we have enough information?
-
-       if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
-               $result['message'] .= t('The profile address specified does not provide adequate information.') . EOL;
-               if (!x($ret, 'poll')) {
-                       $result['message'] .= t('No compatible communication protocols or feeds were discovered.') . EOL;
-               }
-               if (!x($ret, 'name')) {
-                       $result['message'] .= t('An author or name was not found.') . EOL;
-               }
-               if (!x($ret, 'url')) {
-                       $result['message'] .= t('No browser URL could be matched to this address.') . EOL;
-               }
-               if (strpos($url, '@') !== false) {
-                       $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
-                       $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL;
-               }
-               return $result;
-       }
-
-       if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
-               $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
-               $ret['notify'] = '';
-       }
-
-       if (!$ret['notify']) {
-               $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
-       }
-
-       $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
-
-       $subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
-
-       $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
-
-       if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) {
-               $writeable = 1;
-       }
-
-       // check if we already have a contact
-       // the poll url is more reliable than the profile url, as we may have
-       // indirect links or webfinger links
-
-       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1",
-               intval($uid),
-               dbesc($ret['poll']),
-               dbesc(normalise_link($ret['poll'])),
-               dbesc($ret['network'])
-       );
-
-       if (!DBM::is_result($r)) {
-               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
-                       intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
-               );
-       }
-
-       if (DBM::is_result($r)) {
-               // update contact
-               $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
-
-               $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
-               dba::update('contact', $fields, array('id' => $r[0]['id']));
-       } else {
-               $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
-
-               // create contact record
-               q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,
-                       `writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` )
-                       VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ",
-                       intval($uid),
-                       dbesc(datetime_convert()),
-                       dbesc($ret['url']),
-                       dbesc(normalise_link($ret['url'])),
-                       dbesc($ret['addr']),
-                       dbesc($ret['alias']),
-                       dbesc($ret['batch']),
-                       dbesc($ret['notify']),
-                       dbesc($ret['poll']),
-                       dbesc($ret['poco']),
-                       dbesc($ret['name']),
-                       dbesc($ret['nick']),
-                       dbesc($ret['network']),
-                       dbesc($ret['pubkey']),
-                       intval($new_relation),
-                       intval($ret['priority']),
-                       intval($writeable),
-                       intval($hidden),
-                       intval($subhub)
-               );
-       }
-
-       $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
-               dbesc($ret['url']),
-               dbesc($ret['network']),
-               intval($uid)
-       );
-
-       if (!DBM::is_result($r)) {
-               $result['message'] .= t('Unable to retrieve contact information.') . EOL;
-               return $result;
-       }
-
-       $contact = $r[0];
-       $contact_id = $r[0]['id'];
-       $result['cid'] = $contact_id;
-
-       Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);
-
-       // Update the avatar
-       Contact::updateAvatar($ret['photo'], $uid, $contact_id);
-
-       // pull feed and consume it, which should subscribe to the hub.
-
-       Worker::add(PRIORITY_HIGH, "OnePoll", $contact_id, "force");
-
-       $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
-                       WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
-                       intval($uid)
-       );
-
-       if (DBM::is_result($r)) {
-               if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
-                       // create a follow slap
-                       $item = array();
-                       $item['verb'] = ACTIVITY_FOLLOW;
-                       $item['follow'] = $contact["url"];
-                       $slap = OStatus::salmon($item, $r[0]);
-                       Salmon::slapper($r[0], $contact['notify'], $slap);
-               }
-
-               if ($contact['network'] == NETWORK_DIASPORA) {
-                       $ret = Diaspora::sendShare($a->user, $contact);
-                       logger('share returns: ' . $ret);
-               }
-       }
-
-       $result['success'] = true;
-       return $result;
-}
index 0b763d687c69294752cbc64ade24f198748fc932..7ed561bbbbf0d21aae96885e4c85089d1f863dc5 100644 (file)
@@ -3,6 +3,7 @@
  * @file include/text.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Content\Smilies;
 use Friendica\Core\Config;
@@ -2048,16 +2049,14 @@ function formatBytes($bytes, $precision = 2) {
  */
 function format_network_name($network, $url = 0) {
        if ($network != "") {
-               require_once 'include/contact_selectors.php';
                if ($url != "") {
-                       $network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
+                       $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
                } else {
-                       $network_name = network_to_name($network);
+                       $network_name = ContactSelector::networkToName($network);
                }
 
                return $network_name;
        }
-
 }
 
 /**
index 9d6a6b0c7bda9345be974c35ba2f3ece97806718..88dddb3ee66f9256f0b953d41d81e89e78f6f50a 100644 (file)
@@ -4,12 +4,12 @@
  * @file mod/allfriends.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 
-require_once 'include/contact_selectors.php';
 require_once 'mod/contacts.php';
 
 function allfriends_content(App $a)
@@ -86,7 +86,7 @@ function allfriends_content(App $a)
                        'tags'         => $contact_details['keywords'],
                        'about'        => $contact_details['about'],
                        'account_type' => Contact::getAccountType($contact_details),
-                       'network'      => network_to_name($contact_details['network'], $contact_details['url']),
+                       'network'      => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
                        'photo_menu'   => $photo_menu,
                        'conntxt'      => t('Connect'),
                        'connlnk'      => $connlnk,
index fc8829aa51a1c42a8fa5765eca123788fec4dd87..1f1e8c33770f6b99bcbd46af57f803aaa59fccee 100644 (file)
@@ -4,11 +4,11 @@
  * @file include/common.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 
-require_once 'include/contact_selectors.php';
 require_once 'mod/contacts.php';
 
 function common_content(App $a)
@@ -130,7 +130,7 @@ function common_content(App $a)
                        'tags'         => $contact_details['keywords'],
                        'about'        => $contact_details['about'],
                        'account_type' => Contact::getAccountType($contact_details),
-                       'network'      => network_to_name($contact_details['network'], $contact_details['url']),
+                       'network'      => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
                        'photo_menu'   => $photo_menu,
                        'id'           => ++$id,
                );
index b347617a1c2bebf1f948b5d397bc5481b3119a9a..a63591713a70343c710aa702b88ce966fa012709 100644 (file)
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * @file mod/contacts.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
@@ -12,9 +12,7 @@ use Friendica\Model\GContact;
 use Friendica\Model\Group;
 use Friendica\Network\Probe;
 
-require_once 'include/contact_selectors.php';
 require_once 'include/contact_widgets.php';
-require_once 'include/follow.php';
 require_once 'mod/proxy.php';
 
 function contacts_init(App $a)
@@ -243,7 +241,7 @@ function _contact_update($contact_id)
        $uid = $contact["uid"];
 
        if ($r[0]["network"] == NETWORK_OSTATUS) {
-               $result = new_contact($uid, $contact["url"], false, $contact["network"]);
+               $result = Contact::createFromProbe($uid, $contact["url"], false, $contact["network"]);
 
                if ($result['success']) {
                        q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", intval($contact_id));
@@ -275,7 +273,7 @@ function _contact_update_profile($contact_id)
        $update = array();
 
        if ($data["network"] == NETWORK_OSTATUS) {
-               $result = new_contact($uid, $data["url"], false);
+               $result = Contact::createFromProbe($uid, $data["url"], false);
 
                if ($result['success']) {
                        $update["subhub"] = true;
@@ -507,8 +505,6 @@ function contacts_content(App $a)
                        '$baseurl' => System::baseUrl(true),
                ));
 
-               require_once 'include/contact_selectors.php';
-
                $dir_icon = '';
                $relation_text = '';
                switch ($contact['rel']) {
@@ -553,7 +549,7 @@ function contacts_content(App $a)
 
                $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL));
 
-               $nettype = t('Network type: %s', network_to_name($contact['network'], $contact["url"]));
+               $nettype = t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
 
                // tabs
                $tab_str = contacts_tab($a, $contact_id, 2);
@@ -577,12 +573,12 @@ function contacts_content(App $a)
 
                $poll_interval = null;
                if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) {
-                       $poll_interval = contact_poll_interval($contact['priority'], (!$poll_enabled));
+                       $poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled));
                }
 
                $profile_select = null;
                if ($contact['network'] == NETWORK_DFRN) {
-                       $profile_select = contact_profile_assign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
+                       $profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
                }
 
                $follow = '';
@@ -809,7 +805,7 @@ function contacts_content(App $a)
        $tpl = get_markup_template("contacts-template.tpl");
        $o .= replace_macros($tpl, array(
                '$baseurl' => System::baseUrl(),
-               '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
+               '$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''),
                '$tabs' => $t,
                '$total' => $total,
                '$search' => $search_hdr,
@@ -960,7 +956,7 @@ function _contact_detail_for_template($rr)
                'sparkle' => $sparkle,
                'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
                'url' => $url,
-               'network' => network_to_name($rr['network'], $rr['url']),
+               'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
        );
 }
 
index 1a135a602f23e3234a09a4c456be6dc0812a6d3e..12bfc302f74fe0dce870c5d71f8e070fcc273f02 100644 (file)
@@ -8,7 +8,6 @@ use Friendica\Core\Config;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 
-require_once 'include/contact_selectors.php';
 require_once 'mod/contacts.php';
 
 function crepair_init(App $a)
index bef89a4794ce1f74b0bf7da01cdd3b74244a9792..06bb1d8da6684a847f6635587939ed1e3eacf915 100644 (file)
@@ -3,6 +3,7 @@
  * @file mod/dirfind.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -12,7 +13,6 @@ use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 
 require_once 'include/contact_widgets.php';
-require_once 'include/contact_selectors.php';
 require_once 'mod/contacts.php';
 
 function dirfind_init(App $a) {
@@ -235,7 +235,7 @@ function dirfind_content(App $a, $prefix = "") {
                                        'tags'          => $contact_details['keywords'],
                                        'about'         => $contact_details['about'],
                                        'account_type'  => Contact::getAccountType($contact_details),
-                                       'network' => network_to_name($jj->network, $jj->url),
+                                       'network' => ContactSelector::networkToName($jj->network, $jj->url),
                                        'id' => ++$id,
                                );
                                $entries[] = $entry;
index 41c008da514aeb9169c7a6d693fb715673526185..2194321de8bad5fb4cac601caaab46d82c367e66 100644 (file)
@@ -1,13 +1,13 @@
 <?php
-
+/**
+ * @file mod/follow.php
+ */
 use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Model\Contact;
 use Friendica\Network\Probe;
 
-require_once 'include/follow.php';
-require_once 'include/contact_selectors.php';
 
 function follow_post(App $a) {
 
@@ -29,7 +29,7 @@ function follow_post(App $a) {
        // This is just a precaution if maybe this page is called somewhere directly via POST
        $_SESSION["fastlane"] = $url;
 
-       $result = new_contact($uid,$url,true);
+       $result = Contact::createFromProbe($uid, $url, true);
 
        if ($result['success'] == false) {
                if ($result['message']) {
index 59ea6c88b0efd7b2fd2af6e3fdb8314bbf3de716..0d088c02c8652abca44cd6788566b7dc9b6d9495 100644 (file)
@@ -1,11 +1,11 @@
 <?php
-
+/**
+ * @file mod/fsuggest.php
+ */
 use Friendica\App;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 
-require_once 'include/follow.php';
-
 function fsuggest_post(App $a) {
 
        if (! local_user()) {
index 9f5425d9eb7c36604432d2106b895cd8ef75b723..7ebb5bd1f2179852e57ace38dbfa0cbd764c92ed 100644 (file)
@@ -3,12 +3,11 @@
  * @file mod/nogroup.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
 
-require_once 'include/contact_selectors.php';
-
 function nogroup_init(App $a)
 {
        if (! local_user()) {
@@ -53,7 +52,7 @@ function nogroup_content(App $a)
                                'about'         => $contact_details['about'],
                                'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
                                'url' => $rr['url'],
-                               'network' => network_to_name($rr['network'], $rr['url']),
+                               'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
                        );
                }
        }
index fe8422cc4a80a31460923c07fd44dc257893675d..e2de81e6c7f24a7f49dfe41602298fbe7c1d0b10 100644 (file)
@@ -1,17 +1,15 @@
 <?php
-
 /**
  * @file mod/notifications.php
  * @brief The notifications module
  */
-
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\NotificationsManager;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 
-require_once("include/contact_selectors.php");
-require_once("include/network.php");
+require_once "include/network.php";
 
 function notifications_post(App $a) {
 
@@ -225,7 +223,7 @@ function notifications_content(App $a) {
                                        if ($it["addr"] != "")
                                                $header .= " <".$it["addr"].">";
 
-                                       $header .= " (".network_to_name($it['network'], $it['url']).")";
+                                       $header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
 
                                        if ($it['network'] != NETWORK_DIASPORA) {
                                                $discard = t('Discard');
@@ -260,7 +258,7 @@ function notifications_content(App $a) {
                                                '$addr' => $it['addr'],
                                                '$lbl_knowyou' => $lbl_knowyou,
                                                '$lbl_network' => t('Network:'),
-                                               '$network' => network_to_name($it['network'], $it['url']),
+                                               '$network' => ContactSelector::networkToName($it['network'], $it['url']),
                                                '$knowyou' => $knowyou,
                                                '$approve' => t('Approve'),
                                                '$note' => $it['note'],
index 70a36559e4483edf0ed4ca71e11619331f0fb870..9ec58e6f113695c136003bd5533f63127fa2bc94 100644 (file)
@@ -1,12 +1,13 @@
 <?php
-
+/**
+ * @file mod/ostatus_subscribe.php
+ */
 use Friendica\App;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
+use Friendica\Model\Contact;
 use Friendica\Network\Probe;
 
-require_once 'include/follow.php';
-
 function ostatus_subscribe_content(App $a) {
 
        if (! local_user()) {
@@ -67,7 +68,7 @@ function ostatus_subscribe_content(App $a) {
 
        $data = Probe::uri($url);
        if ($data["network"] == NETWORK_OSTATUS) {
-               $result = new_contact($uid, $url, true, NETWORK_OSTATUS);
+               $result = Contact::createFromProbe($uid, $url, true, NETWORK_OSTATUS);
                if ($result["success"]) {
                        $o .= " - ".t("success");
                } else {
index 3372d0326117833a680dd4d75a14a2b08791f7c6..5b207c28606aa8aa0f0803dc1455c500782f73ad 100644 (file)
@@ -1,9 +1,10 @@
 <?php
-
+/**
+ * @file mod/repair_ostatus.php
+ */
 use Friendica\App;
 use Friendica\Core\System;
-
-require_once 'include/follow.php';
+use Friendica\Model\Contact;
 
 function repair_ostatus_content(App $a) {
 
@@ -51,7 +52,7 @@ function repair_ostatus_content(App $a) {
 
        $o .= "<p>".t("Keep this window open until done.")."</p>";
 
-       $result = new_contact($uid,$r[0]["url"],true);
+       $result = Contact::createFromProbe($uid,$r[0]["url"],true);
 
        $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.System::baseUrl().'/repair_ostatus?counter='.$counter.'">';
 
index bd08431a4cfeea8f5a878c5845b6656647f6ad32..3a4dececdeeb87083cd696b5a570295ca52aef0d 100644 (file)
@@ -5,12 +5,12 @@
 use Friendica\App;
 use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
+use Friendica\Model\Contact;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\Salmon;
 use Friendica\Util\Crypto;
 
 require_once 'include/items.php';
-require_once 'include/follow.php';
 
 function salmon_return($val) {
 
@@ -164,7 +164,7 @@ function salmon_post(App $a) {
        if (! DBM::is_result($r)) {
                logger('mod-salmon: Author unknown to us.');
                if(PConfig::get($importer['uid'],'system','ostatus_autofriend')) {
-                       $result = new_contact($importer['uid'],$author_link);
+                       $result = Contact::createFromProbe($importer['uid'], $author_link);
                        if($result['success']) {
                                $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
                                        AND `uid` = %d LIMIT 1",
index deda2b2c6c93bbfdb5738c6807ac2d5b4ddad0a3..05a720f7b986704c48c5471c3d4f3fd2417bdbf6 100644 (file)
@@ -3,6 +3,7 @@
  * @file mod/suggest.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
@@ -76,8 +77,6 @@ function suggest_content(App $a) {
                return $o;
        }
 
-       require_once 'include/contact_selectors.php';
-
        foreach ($r as $rr) {
 
                $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
@@ -106,7 +105,7 @@ function suggest_content(App $a) {
                        'connlnk' => $connlnk,
                        'photo_menu' => $photo_menu,
                        'ignore' => t('Ignore/Hide'),
-                       'network' => network_to_name($rr['network'], $rr['url']),
+                       'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
                        'id' => ++$id,
                );
                $entries[] = $entry;
index 907982cd8a023eccbe842c2114d44150c5dd0237..046fdfe7d6e9fc57111bae34ca35b0a40d7ebcd1 100644 (file)
@@ -1,13 +1,12 @@
 <?php
-
+/**
+ * @file mod/unfollow.php
+ */
 use Friendica\App;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 
-require_once 'include/follow.php';
-require_once 'include/contact_selectors.php';
-
 function unfollow_post(App $a) {
 
        if (!local_user()) {
index 1b4ff69c00285ad4b61f6536b0f4db084d479774..e4ebe3abb2d7e3e4095080ce168d548f225bd7cd 100644 (file)
@@ -1,12 +1,11 @@
 <?php
 
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 
-require_once('include/contact_selectors.php');
-
 function viewcontacts_init(App $a) {
 
        if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
@@ -116,7 +115,7 @@ function viewcontacts_content(App $a) {
                        'url' => $url,
                        'sparkle' => '',
                        'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
-                       'network' => network_to_name($rr['network'], $rr['url']),
+                       'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
                );
        }
 
diff --git a/ruleset.xml b/ruleset.xml
new file mode 100644 (file)
index 0000000..a71b706
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<ruleset name="Friendica">
+    <description>Friendica Coding Standards: PSR2 with tabs instead of spaces</description>
+    <arg name="tab-width" value="4"/>
+    <rule ref="PSR2">
+        <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
+    </rule>
+    <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
+    <rule ref="Generic.WhiteSpace.ScopeIndent">
+        <properties>
+            <property name="indent" value="4"/>
+            <property name="tabIndent" value="true"/>
+        </properties>
+    </rule>
+</ruleset>
diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php
new file mode 100644 (file)
index 0000000..eac7deb
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+/**
+ * @file src/Content/ContactSelector.php
+ */
+namespace Friendica\Content;
+
+use Friendica\Database\DBM;
+use Friendica\Protocol\Diaspora;
+use dba;
+
+/**
+ * @brief ContactSelector class
+ */
+class ContactSelector
+{
+       /**
+        * @param string $current     current
+        * @param string $foreign_net network
+        */
+       public static function profileAssign($current, $foreign_net)
+       {
+               $o = '';
+
+               $disabled = (($foreign_net) ? ' disabled="true" ' : '');
+
+               $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
+
+               $s = dba::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $$_SESSION['uid']]);
+               $r = dba::inArray($s);
+
+               if (DBM::is_result($r)) {
+                       foreach ($r as $rr) {
+                               $selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
+                               $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
+                       }
+               }
+               $o .= "</select>\r\n";
+               return $o;
+       }
+
+       /**
+        * @param string  $current  current
+        * @param boolean $disabled optional, default false
+        * @return object
+        */
+       public static function pollInterval($current, $disabled = false)
+       {
+               $dis = (($disabled) ? ' disabled="disabled" ' : '');
+               $o = '';
+               $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
+
+               $rep = array(
+                       0 => t('Frequently'),
+                       1 => t('Hourly'),
+                       2 => t('Twice daily'),
+                       3 => t('Daily'),
+                       4 => t('Weekly'),
+                       5 => t('Monthly')
+               );
+
+               foreach ($rep as $k => $v) {
+                       $selected = (($k == $current) ? " selected=\"selected\" " : "");
+                       $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
+               }
+               $o .= "</select>\r\n";
+               return $o;
+       }
+
+       /**
+        * @param string $s       network
+        * @param string $profile optional, default empty
+        * @return string
+        */
+       public static function networkToName($s, $profile = "")
+       {
+               $nets = array(
+                       NETWORK_DFRN     => t('Friendica'),
+                       NETWORK_OSTATUS  => t('OStatus'),
+                       NETWORK_FEED     => t('RSS/Atom'),
+                       NETWORK_MAIL     => t('Email'),
+                       NETWORK_DIASPORA => t('Diaspora'),
+                       NETWORK_FACEBOOK => t('Facebook'),
+                       NETWORK_ZOT      => t('Zot!'),
+                       NETWORK_LINKEDIN => t('LinkedIn'),
+                       NETWORK_XMPP     => t('XMPP/IM'),
+                       NETWORK_MYSPACE  => t('MySpace'),
+                       NETWORK_GPLUS    => t('Google+'),
+                       NETWORK_PUMPIO   => t('pump.io'),
+                       NETWORK_TWITTER  => t('Twitter'),
+                       NETWORK_DIASPORA2 => t('Diaspora Connector'),
+                       NETWORK_STATUSNET => t('GNU Social Connector'),
+                       NETWORK_PNUT      => t('pnut'),
+                       NETWORK_APPNET => t('App.net')
+               );
+
+               call_hooks('network_to_name', $nets);
+
+               $search  = array_keys($nets);
+               $replace = array_values($nets);
+
+               $networkname = str_replace($search, $replace, $s);
+
+               if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
+                       $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
+                                       INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
+                                       WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
+
+                       if (DBM::is_result($r)) {
+                               $networkname = $r['platform'];
+                       }
+               }
+
+               return $networkname;
+       }
+}
index 3e8b1f5d65ce26a10956ee7ffc90ce05f9321c55..b0f5ef9f244a3fde42ea33c4d565cc8b32eadd5c 100644 (file)
@@ -7,6 +7,7 @@
 namespace Friendica\Model;
 
 use Friendica\BaseObject;
+use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -16,6 +17,7 @@ use Friendica\Model\Photo;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\OStatus;
+use Friendica\Protocol\PortableContact;
 use Friendica\Protocol\Salmon;
 use dba;
 
@@ -1009,4 +1011,283 @@ class Contact extends BaseObject
 
                return $data;
        }
+
+       /**
+        * @param integer $id contact id
+        * @return boolean
+        */
+       public static function updateFromProbe($id)
+       {
+               /*
+               Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
+               This will reliably kill your communication with Friendica contacts.
+               */
+
+               $r = dba::select('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id], ['limit' => 1]);
+               if (!DBM::is_result($r)) {
+                       return false;
+               }
+
+               $ret = Probe::uri($r["url"]);
+
+               // If Probe::uri fails the network code will be different
+               if ($ret["network"] != $r["network"]) {
+                       return false;
+               }
+
+               $update = false;
+
+               // make sure to not overwrite existing values with blank entries
+               foreach ($ret as $key => $val) {
+                       if (isset($r[$key]) && ($r[$key] != "") && ($val == ""))
+                               $ret[$key] = $r[$key];
+
+                       if (isset($r[$key]) && ($ret[$key] != $r[$key]))
+                               $update = true;
+               }
+
+               if (!$update) {
+                       return true;
+               }
+
+               dba::update(
+                       'contact',
+                       [
+                               'url' => $ret['url'],
+                               'nurl' => normalise_link($ret['url']),
+                               'addr' => $ret['addr'],
+                               'alias' => $ret['alias'],
+                               'batch' => $ret['batch'],
+                               'notify' => $ret['notify'],
+                               'poll' => $ret['poll'],
+                               'poco' => $ret['poco']
+                       ],
+                       ['id' => $id]
+               );
+
+               // Update the corresponding gcontact entry
+               PortableContact::lastUpdated($ret["url"]);
+
+               return true;
+       }
+
+       /**
+        * Takes a $uid and a url/handle and adds a new contact
+        * Currently if the contact is DFRN, interactive needs to be true, to redirect to the
+        * dfrn_request page.
+        *
+        * Otherwise this can be used to bulk add statusnet contacts, twitter contacts, etc.
+        *
+        * Returns an array
+        * $return['success'] boolean true if successful
+        * $return['message'] error text if success is false.
+        *
+        * @brief Takes a $uid and a url/handle and adds a new contact
+        * @param int    $uid
+        * @param string $url
+        * @param bool   $interactive
+        * @param string $network
+        * @return boolean|string
+        */
+       public static function createFromProbe($uid, $url, $interactive = false, $network = '')
+       {
+               $result = array('cid' => -1, 'success' => false, 'message' => '');
+
+               $a = get_app();
+
+               // remove ajax junk, e.g. Twitter
+               $url = str_replace('/#!/', '/', $url);
+
+               if (!allowed_url($url)) {
+                       $result['message'] = t('Disallowed profile URL.');
+                       return $result;
+               }
+
+               if (blocked_url($url)) {
+                       $result['message'] = t('Blocked domain');
+                       return $result;
+               }
+
+               if (!$url) {
+                       $result['message'] = t('Connect URL missing.');
+                       return $result;
+               }
+
+               $arr = array('url' => $url, 'contact' => array());
+
+               call_hooks('follow', $arr);
+
+               if (x($arr['contact'], 'name')) {
+                       $ret = $arr['contact'];
+               } else {
+                       $ret = Probe::uri($url, $network, $uid, false);
+               }
+
+               if (($network != '') && ($ret['network'] != $network)) {
+                       logger('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
+                       return result;
+               }
+
+               if ($ret['network'] === NETWORK_DFRN) {
+                       if ($interactive) {
+                               if (strlen($a->path)) {
+                                       $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
+                               } else {
+                                       $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+                               }
+
+                               goaway($ret['request'] . "&addr=$myaddr");
+
+                               // NOTREACHED
+                       }
+               } elseif (Config::get('system', 'dfrn_only')) {
+                       $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
+                       $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
+                       return $result;
+               }
+
+               // This extra param just confuses things, remove it
+               if ($ret['network'] === NETWORK_DIASPORA) {
+                       $ret['url'] = str_replace('?absolute=true', '', $ret['url']);
+               }
+
+               // do we have enough information?
+
+               if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
+                       $result['message'] .= t('The profile address specified does not provide adequate information.') . EOL;
+                       if (!x($ret, 'poll')) {
+                               $result['message'] .= t('No compatible communication protocols or feeds were discovered.') . EOL;
+                       }
+                       if (!x($ret, 'name')) {
+                               $result['message'] .= t('An author or name was not found.') . EOL;
+                       }
+                       if (!x($ret, 'url')) {
+                               $result['message'] .= t('No browser URL could be matched to this address.') . EOL;
+                       }
+                       if (strpos($url, '@') !== false) {
+                               $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
+                               $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL;
+                       }
+                       return $result;
+               }
+
+               if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
+                       $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
+                       $ret['notify'] = '';
+               }
+
+               if (!$ret['notify']) {
+                       $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
+               }
+
+               $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
+
+               $subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
+
+               $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
+
+               if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) {
+                       $writeable = 1;
+               }
+
+               // check if we already have a contact
+               // the poll url is more reliable than the profile url, as we may have
+               // indirect links or webfinger links
+
+               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1",
+                       intval($uid),
+                       dbesc($ret['poll']),
+                       dbesc(normalise_link($ret['poll'])),
+                       dbesc($ret['network'])
+               );
+
+               if (!DBM::is_result($r)) {
+                       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
+                               intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
+                       );
+               }
+
+               if (DBM::is_result($r)) {
+                       // update contact
+                       $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+
+                       $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
+                       dba::update('contact', $fields, array('id' => $r[0]['id']));
+               } else {
+                       $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+
+                       // create contact record
+                       dba::insert(
+                               'contact',
+                               [
+                                       'uid' => $uid,
+                                       'created' => datetime_convert(),
+                                       'url' => $ret['url'],
+                                       'nurl' => normalise_link($ret['url']),
+                                       'addr' => $ret['addr'],
+                                       'alias' => $ret['alias'],
+                                       'batch' => $ret['batch'],
+                                       `notify` => $ret['notify'],
+                                       `poll` => $ret['poll'],
+                                       `poco` => $ret['poco'],
+                                       `name` => $ret['name'],
+                                       `nick` => $ret['nick'],
+                                       `network` => $ret['network'],
+                                       `pubkey` => $ret['pubkey'],
+                                       `rel` => $new_relation,
+                                       `priority` => $ret['priority'],
+                                       `writable` => $writeable,
+                                       `hidden` => $hidden,
+                                       `blocked` => 0,
+                                       `readonly` => 0,
+                                       `pending` => 0,
+                                       `subhub` => $subhub
+                               ]
+                       );
+               }
+
+               $r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
+
+               if (!DBM::is_result($r)) {
+                       $result['message'] .= t('Unable to retrieve contact information.') . EOL;
+                       return $result;
+               }
+
+               $contact = $r;
+               $contact_id = $r['id'];
+               $result['cid'] = $contact_id;
+
+               Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);
+
+               // Update the avatar
+               self::updateAvatar($ret['photo'], $uid, $contact_id);
+
+               // pull feed and consume it, which should subscribe to the hub.
+
+               Worker::add(PRIORITY_HIGH, "OnePoll", $contact_id, "force");
+
+               $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
+                               WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
+                               intval($uid)
+               );
+
+               if (DBM::is_result($r)) {
+                       if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
+                               // create a follow slap
+                               $item = array();
+                               $item['verb'] = ACTIVITY_FOLLOW;
+                               $item['follow'] = $contact["url"];
+                               $slap = OStatus::salmon($item, $r[0]);
+                               Salmon::slapper($r[0], $contact['notify'], $slap);
+                       }
+
+                       if ($contact['network'] == NETWORK_DIASPORA) {
+                               $ret = Diaspora::sendShare($a->user, $contact);
+                               logger('share returns: ' . $ret);
+                       }
+               }
+
+               $result['success'] = true;
+               return $result;
+       }
 }
index 97768bf56cd79c663d821e3f49da7c1ea89623cb..9ef00949f4f14d27f3ab81de8e3b688d0064232f 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
 /**
  * @file src/Object/Post.php
  */
-
 namespace Friendica\Object;
 
 use Friendica\BaseObject;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
@@ -397,7 +396,7 @@ class Post extends BaseObject
                        'thread_level'    => $thread_level,
                        'edited'          => $edited,
                        'network'         => $item["item_network"],
-                       'network_name'    => network_to_name($item['item_network'], $profile_link),
+                       'network_name'    => ContactSelector::networkToName($item['item_network'], $profile_link),
                        'received'        => $item['received'],
                        'commented'       => $item['commented'],
                        'created_date'    => $item['created'],
index 3c284b29f51d3e5c5b2dd3d92c3f5d8db7983643..1140f7a4e03113dec01a096ff4b98710ebf6f2a1 100644 (file)
@@ -26,7 +26,6 @@ require_once 'include/bbcode.php';
 require_once 'include/items.php';
 require_once 'mod/share.php';
 require_once 'include/enotify.php';
-require_once 'include/follow.php';
 require_once 'include/api.php';
 require_once 'mod/proxy.php';
 
index 9cb33c471b0c68cacf4d8ae3d150dfff258161e7..a527bf0da13d472be12a2ade6bc473c046435d16 100644 (file)
@@ -13,7 +13,6 @@ use Friendica\Protocol\PortableContact;
 use dba;
 
 require_once 'include/dba.php';
-require_once 'include/follow.php';
 
 Class OnePoll
 {
@@ -118,7 +117,7 @@ Class OnePoll
                                return;
                        }
 
-                       if (!update_contact($contact["id"])) {
+                       if (!Contact::updateFromProbe($contact["id"])) {
                                Contact::markForArchival($contact);
                                logger('Contact is marked dead');
 
index 586ff6d195c0efe8e3f23f1f5d5e85d53496e938..611643b89c606d875abc96d97625e13a44a53daa 100644 (file)
@@ -1,26 +1,8 @@
-<?xml version="1.0"?>
-<ruleset name="PEAR-textlanguagedetect">
- <rule ref="PEAR">
-  <!-- we keep the old php4-style variable names for now -->
-  <exclude name="PEAR.NamingConventions.ValidFunctionName.PublicUnderscore"/>
-  <exclude name="PEAR.NamingConventions.ValidVariableName.PublicUnderscore"/>
-  <exclude name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
-  <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
-  <exclude name="PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
-  <exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact"/>
-  <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
- </rule>
- <description>PSR2 with tabs instead of spaces.</description>
- <arg name="tab-width" value="4"/>
- <rule ref="PSR2">
-     <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
-     <exclude name="Generic.Commenting.DocComment.MissingShort"/>
- </rule>
- <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
- <rule ref="Generic.WhiteSpace.ScopeIndent">
-     <properties>
-         <property name="indent" value="4"/>
-         <property name="tabIndent" value="true"/>
-     </properties>
- </rule>
-</ruleset>
+<?xml version="1.0"?>\r
+<ruleset name="PEAR-textlanguagedetect">\r
+ <rule ref="PEAR">\r
+  <!-- we keep the old php4-style variable names for now -->\r
+  <exclude name="PEAR.NamingConventions.ValidFunctionName.PublicUnderscore"/>\r
+  <exclude name="PEAR.NamingConventions.ValidVariableName.PublicUnderscore"/>\r
+ </rule>\r
+</ruleset>\r