Friendica Global Directory This was the initial Friendica user directory, it was replaced by the friendica-directory.
Go to file
Roland Häder eb8e70d09e
Set CHMOD 777 for Shell script.
2019-01-03 22:50:56 +01:00
assets Put the server list on a single fixed-width column 2017-10-22 17:04:01 -04:00
bin Set CHMOD 777 for Shell script. 2019-01-03 22:50:56 +01:00
images [ImgBot] optimizes images 2018-07-13 14:09:08 +00:00
include Fix PHP Warning about count() 2018-07-10 23:56:30 -04:00
js Rewrite: 2017-05-11 16:49:02 +02:00
library Merge branch 'master' into feature/redesign-prototype 2017-04-20 22:33:41 -04:00
mod Fix PHP Notices 2018-05-07 22:02:16 -04:00
src Remove placeholder header 2018-05-08 03:50:43 -04:00
tests This is an example of autoloading classes and including unit tests. 2014-10-11 00:13:59 +02:00
util Add console commands 2018-05-04 08:16:36 -04:00
view [ImgBot] optimizes images 2018-07-13 14:09:08 +00:00
.gitignore Let's have .htaccess not being committed 2018-05-01 23:40:57 +02:00
.htaccess-dist Let's have .htaccess not being committed 2018-05-01 23:40:57 +02:00
Makefile This is an example of autoloading classes and including unit tests. 2014-10-11 00:13:59 +02:00
README.md Let's have .htaccess not being committed 2018-05-01 23:40:57 +02:00
Vagrantfile Vagrant > 1.5 needs an additional parameter 2017-08-01 17:04:03 +02:00
boot.php Fix cron_maintain 2017-10-22 23:48:00 -04:00
composer.json Remove obsolete repositories key from composer.json 2018-11-08 07:11:43 -05:00
composer.lock Bump mrpetovan/net_ping to version 1.1.1 2018-11-08 07:18:11 -05:00
dfrndir.sql Prevent infinite push loop between multiple directories 2018-05-07 22:02:16 -04:00
example.php Switched to composer generated autoloader. 2015-02-08 18:24:49 +01:00
htconfig.php Merge branch 'feature/redesign-prototype' of https://github.com/tugelbend/dir into feature/redesign-prototype 2017-04-20 19:32:52 -04:00
index.php Fix display issues 2018-01-14 22:22:37 -05:00
maintenance.html Fix deprecated constant MYSQL_ASSOC 2017-08-01 19:39:34 -04:00

README.md

Decentralized Friendica Directory

Installing

1. Copy configuration

Copy the htconfig.php to .htconfig.php and enter the database credentials.

2. Initialize the database

Create a database with a username and a password. Then import dfrndir.sql to it.

mysql -u YOURDBUSER -p YOURDBNAME < dfrnlr.sql

3. Create an autoloader with composer

Make sure you have composer installed globally, or rewrite the command to use a .phar.

composer dump-autoload

4. Set up the cronjobs.

Example cronjob using www-data user.

*/30 * * * * www-data cd /var/www/friendica-directory; php include/cron_maintain.php
*/5  * * * * www-data cd /var/www/friendica-directory; php include/cron_sync.php

5. Copy .htaccess-dist to .htaccess and make local modifications

How syncing works

The new syncing features include: pushing and pulling.

Pushing

Submissions you receive can be submitted to other directories using a push target.

You do this by creating an entry in the sync-targets table with the push bit set to 1. Also, you must enable pushing in your .htconfig settings.

The next time include/cron_sync.php is run from your cronjob, the queued items will be submitted to your push targets.

Pulling

For pulling to work, the target server must enable pulling. This makes the /sync/pull/all and /sync/pull/since/[when] methods work on that server.

Next you can add an entry in the sync-targets table with the pull bit set to 1. Also, you must enable pulling in your .htconfig settings.

The next time include/cron_sync.php is run from your cronjob, the pulling sources will be checked. New items will be queued in your pull queue. The queue will be gradually cleared based on your syncing.max_pull_items settings. You can check the backlog of this queue at the /admin page.

Note: If you set the bit for pulling or pushing in the MySQL console, it won't be visible in a SELECT query. MySQL will however inform you about changed rows after UPDATE queries.

How submissions are processed

  1. The /submit endpoint takes a ?url= parameter. This parameter is an encoded URL, the original ASCII is treated as binary and base16 encoded. This URL should be a profile location, such as https://fc.oscp.info/profile/admin. This URL will be checked in the database for existing accounts. This check includes a normalization, http vs https is ignored as well as www. prefixes.

  2. If noscrape is supported by the site, this will be used instead of a scrape request. In this case https://fc.oscp.info/noscrape/admin. If noscrape fails or is not supported, the url provided (as is) will be scraped for meta information.

    • <meta name="dfrn-global-visibility" content="true" />
    • <meta name="friendica.community" content="true" /> or <meta name="friendika.community" content="true" />
    • <meta name="keywords" content="these,are,your,public,tags" />
    • <link rel="dfrn-*" href="https://fc.oscp.info/*" /> any dfrn-* prefixed link and it's href attribute.
    • .vcard .fn as fn
    • .vcard .title as pdesc
    • .vcard .photo as photo
    • .vcard .key as key
    • .vcard .locality as locality
    • .vcard .region as region
    • .vcard .postal-code as postal-code
    • .vcard .country-name as country-name
  3. If the dfrn-global-visibility value is set to false. Any existing records will be deleted. And the process exits here.

  4. A submission is IGNORED when at least the following data could not be scraped.

    • key the public key from the hCard.
    • dfrn-request required for the DFRN protocol.
    • dfrn-confirm required for the DFRN protocol.
    • dfrn-notify required for the DFRN protocol.
    • dfrn-poll required for the DFRN protocol.
  5. If the profile existed in the database and the profile is not explicitly set to public using the dfrn-global-visibility meta tag. It will be deleted.

  6. If the profile existed in the database and the profile lacks either an fn or photo attribute, it will be deleted.

  7. The profile is now inserted/updated based on the found information. Notable database fields are:

    • homepage the originally (decoded) ?url= parameter.
    • nurl the normalized URL created to remove http vs https and www vs non-www urls.
    • created the creation date and time in UTC (now if the entry did not exist yet).
    • updated the current date and time in UTC.
  8. If an insert has occurred, the URL will now be used to check for duplicates. The highest insert ID will be kept, anything else deleted.

  9. If provided, your public tags are now split by (space character) and stored in the tags table. This uses your normalized URL as unique key for your profile.

  10. The photo provided will be downloaded and resized to 80x80, regardless of source size.

  11. Should there somehow have been an error at this point such as that there is no profile ID known. Everything will get deleted based on the original ?url= parameter.

The Directory uses MySQL fulltext capabilities to index profiles and offer a search feature. However, the default minimum word size MySQL will index is 4, which ignores words like PHP and USA.

To index words smaller than 4 characters, you will have to edit your my.cnf/my.ini file to include this:

[mysqld]
ft_min_word_len = 3

Then restart your MySQL server.

If you already had data in your profile table, you will need to rebuild the index by executing the following query:

REPAIR TABLE `profile` QUICK;