carlos22 / carddav2fb

:notebook: A command-line PHP script allowing to import CardDAV-based VCards (e.g. from 'owncloud') to a phonebook in a AVM FRITZ!Box
The Unlicense
86 stars 68 forks source link

a lot of errors, but i seems to work... (php7) #24

Open DjSni opened 6 years ago

DjSni commented 6 years ago

carddav2fb.php 1.11 (2016-05-12) - CardDAV to FRITZ!Box phonebook conversion tool Copyright (c) 2012-2016 Karl Glatz, Martin Rost, Jens Maus, Johannes Freiburger

Retrieving VCards from all CardDAV server(s): [0]: https://carddav.fastmail.com/dav/addressbooks/user/xxxx/Default/ .................................................................................................................................................................................... 180 VCards retrieved. PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 WARNING: No fullname, lastname, orgname or formatted name found! PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320 Done. Converting VCards to FritzBox XML format: WARNING: Only VCard embedded photo data or a reference URL is currently supported. VCard: 'UNKNOWN' WARNING: no phone entry found. VCard will be ignored. VCard: 'UNKNOWN' WARNING: no phone entry found. VCard will be ignored. VCard: 'xxx' WARNING: Only VCard embedded photo data or a reference URL is currently supported. [....] Done. Upload data to FRITZ!Box @ 192.168.x.x Uploading Phonebook XML to 192.168.x.x FRITZ!Box returned message: 'FRITZ!Box Telefonbuch wiederhergestellt' Done.

DjSni commented 6 years ago

php -v PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )

j-ed commented 5 years ago

PHP Warning: Illegal string offset 'value' in /opt/carddav2fb/lib/vCard-parser/vCard.php on line 320

I had run into that error too, with PHP 7.2.14 and tried to find the root cause of the problem. I found out that the expected record structure looks like this:

Array
(
    [0] => Array
        (
            [value] => /9j/4AAQSkZJRgAB...
            [type] => Array
                (
                    [0] => jpeg
                )

            [encoding] => b
        )
)

Unfortunately the record structure changes some time so that the mentioned warning is displayed:

Array
( 
    [0] => data:image/jpeg;base64,/9j/4AAQSkZJR...
)

I didn't investigate why the record structure is changing but I was able to suppress the message by adding two additional checks to the code:

  1. I added a check if $V is an array or not.
  2. I added a check if the array key 'value' exists.
    # diff -rupN vCard.php.ORG vCard.php
    --- vCard.php.ORG       2019-05-06 12:45:31.805348829 +0200
    +++ vCard.php   2019-05-06 19:20:47.970866487 +0200
    @@ -317,11 +317,17 @@
                                        $Value = $this -> Data[$Key];
                                        foreach ($Value as $K => $V)
                                        {
    -                                               if (stripos($V['value'], 'uri:') === 0)
    -                                               {
    -                                                       $Value[$K]['value'] = substr($V, 4);
    -                                                       $Value[$K]['encoding'] = 'uri';
    -                                               }
    +                        if (is_array($V))
    +                        {
    +                            if (array_key_exists('value', $V))
    +                            {
    +                                if (stripos($V['value'], 'uri:') === 0)
    +                                {
    +                                    $Value[$K]['value'] = substr($V, 4);
    +                                    $Value[$K]['encoding'] = 'uri';
    +                                }
    +                            }
    +                        }
                                        }
                                        return $Value;
                                }

    I hope this will help someone else too, to get rid of the messages.

carlos22 commented 5 years ago

You might look at https://github.com/carlos22/carddav2fb/issues/34.