Sure, here's the mini how-to:
Here's what you need:
.abook files from your users. They are located on /var/www/ispcp/gui/tools/webmail/data on ispcp omega, but they're lost after upgrading to i-mscp, so you'll want to have a backup for this .
This script: (modified from a comment by user k4b3za at http://blog.kxr.me/2010/04/mig…uirrel-mail-contacts.html)
- #!/usr/bin/php -q
- <?php
- // squirrelmail data dir in ispcp omega
- $DATA = "/var/www/ispcp/gui/tools/webmail/data/";
- // i-mscp Roudncube DataBase
- $mysql_link=mysql_pconnect("localhost","root","yourMySQLrootPassword");
- mysql_select_db("ispcp_roundcube");
- $sql = "select user_id,username from users order by user_id";
- $Resp= mysql_query($sql);
- while( $row = mysql_fetch_array($Resp) ){
- $file = $DATA.$row["username"].".abook";
- if(file_exists( $file )){
- $handle = fopen( $file , 'r');
- while (!feof($handle)) {
- $buffer = fgets($handle, 4096);
- if(trim($buffer)){
- list($nick,$nombre,$apellido,$email,$empresa) = explode("|",$buffer);
- if( trim($email) ){
- $sql2 = "select email from contacts where user_id='".$row["user_id"]."' and email='$email' ";
- $Resp2= mysql_query($sql2);
- if(mysql_num_rows($Resp2)==0){
- print "Adding $email to ".$row["username"]." ...";
- $sql3 = "insert into contacts set name = '$nick', firstname = '$nombre',surname = '$apellido', email = '$email',user_id = '".$row["user_id"]."' ";
- $Resp3 = mysql_query($sql3);
- if($Resp3) print " Ok\n";
- else print " Fail\n";
- }
- }
- }
- }
- }
- }
Basically, this script looks for "username.abook" files where "username(s)" are your imported roundcube database users. If it finds any match, it will then open the .abook and will insert nick,name,surname and email fields into roundcube's contact database for that username, unless the email adress for the contact is already there (maybe the user already started to type his/her contacts).
It doesn't handle contact groups or members of groups (don't know if they even existed in squirrelmail).
...so you just run the script and you should be all set. Backup your database first (just in case) and Enjoy!
-Ivan.