Results 1 to 4 of 4

Thread: Importing squirrelmail abook files

  1. #1
    Join Date
    Sep 2006
    Location
    Netherlands, Rotterdam
    Posts
    10
    Rep Power
    9

    Default Importing squirrelmail abook files

    While i was in the process of migrating about 10 users from squirrelmail to zimbra i found that using imapsync did a great job of moving the mail, but i was left with the users adressbooks.

    Found some information on the wiki with a python script that could do the conversion, but it didnt work for me. So i made a rough script in php wich (calling it on the server squirrelmail runs on) sends me a cvs file containing an importable file of contacts for zimbra.

    Of course you will need to edit the code to enter the dir where squirrelmail's .abook files are kept, and it isnt a verry secure thing to do but it worked for me. And as i said earlier... its pritty rough

    Code:
    <?php
    if (empty($userid)) {
     echo "<HTML><HEADER></HEADER><BODY>";
     echo "<form action='/abook.php' method='put'>User";
     echo "<input type='text' name='userid' size='7'></form>";
    }
    
    if (!empty($userid)) {
     header("Content-type: application/force-download");
     header("Content-disposition: attachment; filename=$userid.cvs");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Pragma: nocache");
     print("\"Birthday\",\"Business City\",\"Business Country\",\"Business Fax\",\"Business Phone\",\"Business Phone 2\",\"Business Postal Code\",\"Business State\",\"Business Street\",\"Business Street 2\",\"Business Street 3\",\"Callback\",\"Car Phone\",\"Company\",\"Company Main Phone\",\"Department\",\"E-mail Address\",\"E-mail Display Name\",\"E-mail Type\",\"E-mail 2 Address\",\"E-mail 2 Display Name\",\"E-mail 2 Type\",\"E-mail 3 Address\",\"E-mail 3 Display Name\",\"E-mail 3 Type\",\"First Name\",\"Home City\",\"Home Country\",\"Home Fax\",\"Home Phone\",\"Home Phone 2\",\"Home Postal Code\",\"Home State\",\"Home Street\",\"Home Street 2\",\"Home Street 3\",\"Initials\",\"Job Title\",\"Last Name\",\"Middle Name\",\"Mobile Phone\",\"Notes\",\"Other City\",\"Other Country\",\"Other Fax\",\"Other Phone\",\"Other Postal Code\",\"Other State\",\"Other Street\",\"Other Street 2\",\"Other Street 3\",\"Pager\",\"Suffix\",\"Web Page\"
    ");
     $readfile = file("/var/squirrelmail/prefs/".$userid.".abook");
     for ($k=0; $k<=count($readfile)-1; $k++) {
      $fields = split("\|",$readfile[$k]);
      print("\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[3]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[1]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[2]\",\"\",\"\",\"$fields[4]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"
    ");
     }
    }
    ?>
    i named it 'abook.php' and called it like http://server/abook.php?userid=username
    wich in turn returns a download username.cvs....

    Hope someone has use for it, and its posted in the proper place.

  2. #2
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

    Default

    Welcome to the forums and thanks for your effort with that script.

    Could you add it to the wiki if you have time, it's editable by everyone.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    Join Date
    Sep 2006
    Location
    Netherlands, Rotterdam
    Posts
    10
    Rep Power
    9

    Default

    Thanks for the welcome, just thought id share

    Its on the wiki too, hope its ok that way.

    John
    Wiki Squirrelmail abook php script

  4. #4
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

    Default

    Yes, it looks fine to me. Anything else you'd like to share - feel free.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

Similar Threads

  1. importing from thunderbird mbox files
    By iwoodnt in forum Installation
    Replies: 9
    Last Post: 09-22-2011, 08:37 AM
  2. Replies: 8
    Last Post: 02-27-2007, 04:10 AM
  3. svn version still won't start
    By kinaole in forum Developers
    Replies: 0
    Last Post: 10-04-2006, 07:47 AM
  4. Replies: 16
    Last Post: 09-07-2006, 07:39 AM
  5. importing raw files
    By rmvg in forum Administrators
    Replies: 1
    Last Post: 10-08-2005, 01:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •