Using a php script to convert squirrelmail .abook files to zimbra cvs: Difference between revisions

No edit summary
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.
{{Archive}}{{Unsupported}}


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.
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' addressbooks.


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 ;)
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 which (calling it on the server squirrelmail runs on) sends me a cvs file containing an importable file of contacts for zimbra.


abook.php {
Of course you will need to edit the code to enter the dir where squirrelmail's .abook files are kept, and it isn't a very secure thing to do but it worked for me. And as I said earlier... its pretty rough ;)
 
abook.php
  <?php
  <?php
  if (empty($userid)) {
  if (empty($userid)) {
Line 12: Line 14:
   echo "<input type='text' name='userid' size='7'></form>";
   echo "<input type='text' name='userid' size='7'></form>";
  }
  }
  if (!empty($userid)) {
  if (!empty($userid)) {
   header("Content-type: application/force-download");
   header("Content-type: application/force-download");
Line 19: Line 20:
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Pragma: nocache");
   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\"
   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\"\t");
");
   $readfile = file("/var/squirrelmail/prefs/".$userid.".abook");
   $readfile = file("/var/squirrelmail/prefs/".$userid.".abook");
   for ($k=0; $k<=count($readfile)-1; $k++) {
   for ($k=0; $k<=count($readfile)-1; $k++) {
   $fields = split("\|",$readfile[$k]);
   $fields = split("\|",$readfile[$k]);
  print("\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[3]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[1]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[2]\",\"\",\"\",\"$fields[4]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"
  print("\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[3]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[1]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"$fields[2]\",\"\",\"\",\"$fields[4]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"\t");
");
   }
   }
  }
  }
  ?>
  ?>
}
 
i named it 'abook.php' and called it like [url]http://server/abook.php?userid=username[/url]
i named it 'abook.php' and called it like http://server/abook.php?userid=username
wich in turn returns a download username.cvs....
wich in turn returns a download username.cvs....


Hope someone has use for it, and its posted in the proper place.
Hope someone has use for it, and its posted in the proper place.
Moved here from  the thread i made on the forum: http://www.zimbra.com/forums/showthread.php?t=4604
{{Article Footer|unknown|9/21/2006}}
[[Category:Migration]]

Latest revision as of 13:03, 24 March 2015


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' addressbooks.

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 which (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 isn't a very secure thing to do but it worked for me. And as I said earlier... its pretty rough ;)

abook.php

<?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\"\t");
 $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]\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"\t");
 }
}
?>

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.

Moved here from the thread i made on the forum: http://www.zimbra.com/forums/showthread.php?t=4604


Verified Against: unknown Date Created: 9/21/2006
Article ID: https://wiki.zimbra.com/index.php?title=Using_a_php_script_to_convert_squirrelmail_.abook_files_to_zimbra_cvs Date Modified: 2015-03-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search