Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference with andig fork #35

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c463546
Initial commit
andig Nov 17, 2017
4eb6f61
Minor
andig Nov 17, 2017
1ee143c
Fix command not found
andig Nov 18, 2017
00294a1
Better version constraints
andig Nov 18, 2017
2990055
Remove fiel artefact
andig Nov 18, 2017
6972ccf
Make executable
andig Nov 18, 2017
1f44b8a
Fix run command
andig Nov 18, 2017
c13468d
Refactor
andig Nov 18, 2017
2674dc0
Refactor dependencies and conversions
andig Nov 18, 2017
549e899
Updated
andig Nov 18, 2017
afdd8a0
Allow specifying config file
andig Nov 19, 2017
882c3f0
Add group mapping
andig Nov 19, 2017
af1af53
Add vip marker
andig Nov 19, 2017
4f81252
Added excluding by category
andig Nov 19, 2017
c3d0720
Fixed conversion config not used
andig Nov 21, 2017
a305ff3
Added highlevel logging
andig Nov 21, 2017
76b2a38
Minor
andig Nov 21, 2017
bbafac4
Fix counting
andig Nov 24, 2017
f187286
Refactored code and config options
andig Nov 24, 2017
0899501
Preparations for launch
blacksenator Nov 24, 2017
8c486a7
Merge pull request #11 from BlackSenator/patch-1
andig Nov 24, 2017
aa6b430
Fix function name
andig Nov 26, 2017
5f703cf
Merge branch 'master' of https://github.com/andig/carddav2fb
andig Nov 26, 2017
b4c0c70
Refactor upload function
andig Nov 27, 2017
6d29520
Add download progress indicator
andig Nov 27, 2017
a662499
Simplify and speed-up download
andig Nov 27, 2017
091b1b1
Add editorconfig
andig Nov 27, 2017
7b31e1c
PSR2 coding style
andig Nov 27, 2017
790fa93
More cleanup
andig Nov 27, 2017
af4bc4c
More cleanup
andig Nov 27, 2017
6a5b091
Fix setAuth
andig Nov 27, 2017
eb690d3
Fix filtering
andig Nov 28, 2017
056ffe1
Fix vip filter
andig Nov 29, 2017
ec73c02
wip
andig Nov 28, 2017
0023e5c
Major refactor
andig Nov 29, 2017
2174760
Remove object typehint
andig Nov 30, 2017
7f61b36
Add include filter
andig Dec 5, 2017
0323aa5
Add matching of array attributes
andig Dec 6, 2017
bc4f09c
Fix json option does not exist
andig Dec 10, 2017
5a07bd1
Added comments
andig Dec 11, 2017
c0a735d
Diverse Korrekturen: Gliederung/Rechtschreibung
blacksenator Dec 14, 2017
d48c728
Polishing
blacksenator Dec 14, 2017
512f54f
Serving suggestion
blacksenator Dec 14, 2017
79005ab
Merge pull request #23 from BlackSenator/patch-3
andig Dec 14, 2017
cb463ca
Update README.md
andig Dec 14, 2017
a77e5a6
Merge pull request #28 from BlackSenator/patch-8
andig Dec 14, 2017
c0e5326
Change default phone formatting
andig Dec 14, 2017
8f9daa2
Support nick names (#35)
blacksenator Jan 16, 2018
330b178
Allow reading multiple sources (#34)
blacksenator Jan 25, 2018
795c3be
[carddav2fb] update of README.MD (#44)
Stefan300381 Apr 12, 2018
756f49e
Validate reading intermediate files (#46)
andig Apr 14, 2018
c8650a7
Add digest authentication (#56)
andig Sep 12, 2018
5ab0057
Fix undefined property (#58)
Sep 17, 2018
b510882
Update README.md (#62)
BFallert Dec 8, 2018
894d174
deletes semicolons that sometimes appear at the end of "ORG:" names (…
blacksenator Dec 11, 2018
f9ce4da
Add image upload (#59)
blacksenator Dec 19, 2018
4e2a913
Update copyright (#65)
blacksenator Dec 19, 2018
8434a99
Image upload documentation (#67)
blacksenator Dec 26, 2018
0d42c55
Image upload error handling (#68)
blacksenator Dec 26, 2018
1cc2e93
Implements the assignment of quick dial and vanity numbers (#70)
blacksenator Dec 30, 2018
1a2131a
Handler contacts with >9 numbers (#71)
blacksenator Jan 5, 2019
dbb834b
Allow correct filtering even if multiple servers share the same group…
derwok Jan 5, 2019
41c15a0
Various cleanups (#79)
andig Jan 5, 2019
da6c84a
Improve Image Upload (#76)
derwok Jan 5, 2019
d7bea0c
Sort phone numbers by configurable type (#80)
blacksenator Jan 6, 2019
80d6f75
Looks nicer with a LF (#83)
blacksenator Jan 7, 2019
d64492d
Apply php-cs-fixer
andig Jan 8, 2019
42714bf
Update license holders
andig Jan 8, 2019
84c1f42
Force Fritz!Fon image refresh of changed/updated images (#85)
derwok Jan 8, 2019
d7da031
Perform early check if image upload may be possible. Fixes #82 (#86)
derwok Jan 9, 2019
903c357
If ftp_nlist returns false, we now interpret this as empty dir and co…
derwok Jan 12, 2019
ab291da
Show warning on console if more than 150 images on FritzBox. Fixes #9…
derwok Jan 12, 2019
3c3730d
Clean up quote backslashes before some special chars (#91)
derwok Jan 12, 2019
4969295
Simplify file upload
andig Jan 14, 2019
9666521
Ensure base url formatted without trailing /
andig Jan 14, 2019
d3f7730
Use new postFile function
andig Jan 21, 2019
142656e
Merge pull request #96 from andig/api
andig Jan 21, 2019
efe1954
Warn about dslf-conf user (#95)
blacksenator Jan 21, 2019
729ed75
Do not uploads contacts without a phone number (#102)
blacksenator Jan 21, 2019
9ec65a2
Cleanup function names
andig Jan 25, 2019
61e25d8
Rewrite HTTP client handling (#103)
andig Jan 28, 2019
23e2b57
Fix login not public
andig Jan 28, 2019
ddc8fc4
Tweak ftp connection
andig Jan 28, 2019
09a7ae8
Tweak ftp connection (#104)
andig Jan 28, 2019
1a80858
Setup CI (#105)
andig Jan 28, 2019
8e74117
Fix validation errors
andig Jan 28, 2019
49488be
Fix validation errors
andig Jan 28, 2019
4c38db1
Fix refactoring errors
andig Jan 29, 2019
2f97f58
Further simplify converter code
andig Jan 29, 2019
e430a6d
ftp: use passive mode (#109)
mtdcr Jan 31, 2019
30fab4f
Fix contacts download empty
andig Feb 5, 2019
7052430
Align extension handling with url path trimming
andig Feb 5, 2019
22c4512
Revert 70524306d780422ce9e59354ca535d0b8542b2e7
andig Feb 6, 2019
46cae0e
Cache http client (#116)
andig Feb 8, 2019
3ce70ea
Update README.md
andig Feb 10, 2019
d765ed7
Handle contacts with >9 phone numbers (#117)
andig Feb 13, 2019
a0e470d
Add unit tests (#121)
andig Feb 14, 2019
bd850eb
Update README.md
andig Feb 14, 2019
05fca26
typo (#125)
mokkin Mar 10, 2019
8511ffc
Gracefully handle failed card downloads (#127)
andig Mar 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# PHP PSR-2 Coding Standards
# http://www.php-fig.org/psr/psr-2/

root = true

[*.php]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/composer.lock
/config.php
/cards.xml
/vendor/
php-cs-fixer.config
14 changes: 14 additions & 0 deletions .php_cs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('src')
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
->setUsingCache(false)
;
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
sudo: false

language: php

cache:
directories:
- $HOME/.composer/cache

install:
- composer install

matrix:
fast_finish: true

jobs:
include:
- stage: Test
php: 7.1
script:
phpunit
- stage: Static Analysis
php: 7.1
install:
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- composer require --dev "phpstan/phpstan"
script:
# Static analyzer check
- ./vendor/bin/phpstan analyze --level=5 --no-progress src
- stage: Code Style
php: 7.1
install:
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- composer require --dev "friendsofphp/php-cs-fixer:^2.8"
script:
# Check the code style
- IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS
- ./vendor/bin/php-cs-fixer fix --config=.php_cs.php -v --dry-run --diff --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"
103 changes: 29 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,55 @@
# CardDAV contacts import for AVM FRITZ!Box
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BB3W3WH7GVSNW)

[![Build Status](https://scrutinizer-ci.com/g/jens-maus/carddav2fb/badges/build.png?b=master)](https://scrutinizer-ci.com/g/jens-maus/carddav2fb/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jens-maus/carddav2fb/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jens-maus/carddav2fb/?branch=master)
This is an entirely simplified version of https://github.com/jens-maus/carddav2fb. The Vcard parser has been replaced by an extended version of https://github.com/jeroendesloovere/vcard.

Features:
## Features

* Allows to import CardDAV-based VCard contacts (e.g. from 'owncloud') to a phonebook in a AVM FRITZ!Box
* CardDAV import includes photo images specified in VCards
* No modification of FRITZ!Box firmware (aka FRITZ!OS) required
* Definition of multiple CardDAV accounts and "folders" possible
* Format of full name in FRITZ!Box phonebook can be designed

**CAUTION: This script will overwrite your current contacts in the FritzBox without any warning!**

## Information

This version of carddav2fb is a forked version from carlos22 (https://github.com/carlos22/carddav2fb) and adding support for convenient image upload, different FRITZ!Box base paths (for example for FRITZ!Box 7490 (UI) OS: 6.50) and full name design support.
* download from any number of CardDAV servers
* selection (include/exclude) by categories or groups (e.g. iCloud)
* upload of contact pictures to display them on the FRITZ!Fon (handling see below)
* transfer of quick dial and vanity numbers (see wiki for handling details)
* if more than nine phone numbers are included, the contact will be divided into a corresponding number of phonebook entries (any existing email addresses are assigned to the first set [there is no quantity limit!])
* phone numbers are sorted by type. The order of the conversion values ('phoneTypes') determines the order in the phone book entry
* the contact's UID of the CardDAV server is added to the phonebook entry (not visible in the FRITZ! Box GUI)

## Requirements

* PHP-version 5.3.6 or higher
* PHP-curl module
* PHP-ftp module
* PHP-mbstring module
* PHP >7.0 (`apt-get install php php-curl php-mbstring php-xml`)
* Composer (follow the installation guide at https://getcomposer.org/download/)

## Installation

Checkout the carddav2fb sources including its related subprojects using the following command:
Install requirements

git clone https://github.com/jens-maus/carddav2fb.git
git clone https://github.com/andig/carddav2fb.git
cd carddav2fb
composer install --no-dev

Now you should have everything setup and checked out to a 'carddav2fb' directory.

### Configuration
1. Make sure you have `System -> FRITZ!Box-Users -> Login via Username+Password` in your FRITZ!Box activated.
2. Make sure you have a separate user created under `System -> FRITZ!Box-Users` for which the following access rights have been granted:
* `FRITZ!Box settings` (required to upload telephone book data)
* `Access to NAS content` (required to upload photos via ftp).
3. Make sure the telephone book you are going to update via carddav2fb exists on the FRITZ!Box, otherwise the upload will fail.
4. Copy `config.example.php` to `config.php` and adapt it to your needs including setting the FRITZ!Box user settings.
edit `config.example.php` and save as `config.php`

## Usage

### Ubuntu

1. Install PHP, PHP-curl, PHP-ftp, PHP-mbstring and php-xml module:

sudo apt-get install php-cli php-curl php-ftp php-mbstring php-xml

2. Open a Terminal and execute:

php carddav2fb.php

### Windows
List all commands:

1. Download PHP from [php.net](http://windows.php.net/download/). Extract it to `C:\PHP`.
2. Start -> cmd. Run `C:\PHP\php.exe C:\path\to\carddav2fb\carddav2fb.php`
php carddav2fb.php list

## config.php Example (owncloud)
Complete processing:

$config['fritzbox_ip'] = 'fritz.box';
$config['fritzbox_user'] = '<USERNAME>';
$config['fritzbox_pw'] = '<PASSWORD>';
$config['phonebook_number'] = '0';
$config['phonebook_name'] = 'Telefonbuch';
$config['fritzbox_path'] = 'file:///var/media/ftp/';
php carddav2fb.php run

// full name format options default 0
// parts in '' will only added if existing and switched to true in config
// 0 = 'Prefix' Lastname, Firstname, 'Additional Names', 'Suffix', 'orgname'
// 1 = 'Prefix' Firstname Lastname 'AdditionalNames' 'Suffix' '(orgname)'
// 2 = 'Prefix' Firstname 'AdditionalNames' Lastname 'Suffix' '(orgname)'
$config['fullname_format'] = 0;
Get help for a command:

// fullname parts
$config['prefix'] = false; // include prefix in fullname if existing
$config['suffix'] = false; // include suffix in fullname if existing
$config['addnames'] = false; // include additionalnames in fullname if existing
$config['orgname'] = false; // include organisation (company) in fullname if existing

$config['quickdial_keyword'] = 'Quickdial:'; // once activated you may add 'Quickdial:+49030123456:**709' to the contact note field and the number will be set as quickdialnumber in your FRITZ!Box. It is possible to add more quickdials for one contact each in a new line
php carddav2fb.php run -h

// first
$config['carddav'][0] = array(
'url' => 'https://<HOSTNAME>/remote.php/carddav/addressbooks/<USERNAME>/contacts',
'user' => '<USERNAME>',
'pw' => '<PASSWORD>'
);
## Precondition for using image upload (command -i)

## Note
This script is using third-party libraries for downloading VCards from CardDAV servers based on the following packages
* CardDAV-PHP (https://github.com/jens-maus/CardDAV-PHP.git)
* FRITZ!Box-API-PHP (https://github.com/jens-maus/fritzbox_api_php.git)
* VCard-Parser (https://github.com/jens-maus/vCard-parser.git)
* your memory (USB stick) is indexed [Heimnetz -> Speicher (NAS) -> Speicher an der FRITZ!Box]
* ftp access is activ [Heimnetz -> Speicher (NAS) -> Heimnetzfreigabe]
* you use an standalone user (NOT! dslf-config) which has explicit permissions for FRITZ!Box settings, access to NAS content and read/write permission to all available memory [System -> FRITZ!Box-Benutzer -> [user] -> Berechtigungen]

## License
This script is released under Public Domain.
This script is released under Public Domain, some parts under GNU AGPL or MIT license. Make sure you understand which parts are which.

## Authors
Copyright (c) 2012-2016 Karl Glatz, Martin Rost, Jens Maus, Johannes Freiburger
Copyright (c) 2012-2019 Andreas Götz, Volker Püschel, Karl Glatz, Christian Putzke, Martin Rost, Jens Maus, Johannes Freiburger
Loading