RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > Third Party Contributions > Plug-Ins

For more information about the ads and why they're here, please see the FAQ
Reply
  #1  
Old 10-19-2006, 07:55 PM
Registered User
 
Join Date: Oct 2006
Posts: 11
Downloads: 0
Uploads: 0
Default Import address book from csv file

Pass down the name of the file you want
And the users id that is in the sql table

csv layout
Name, Email

Hope it helps ya all.

Code:
<?php

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'roundcubemail';

mysql_select_db($dbname, $conn);
echo mysql_errno($conn) . ": " . mysql_error($conn). "\n";

///Fin connection

$user_id = $_GET['user_id'];
$file = $_GET['file'];

if($user_id == "" || $file == "")
{
	echo "You have no user id $user_id<br>OR files";
}
if($user_id != "" || $file != "")
{

echo $user_id;
echo "<br>$file";

$row = 1;
$handle = fopen($file, "r");
echo "$handle";

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{

	echo "<br />";
	
	$row++;

	$name = $data[0];
	$email = $data[1];

	echo "<b>Name: </b>" . $name. "\n";
	echo "<B>Email:</B> " . $email . "\n";

	$query = "INSERT INTO `contacts` ( `contact_id` , `user_id` , `changed` , `del` , `name` , `email` , `firstname` , `surname` , `vcard` ) VALUES ( '', '$user_id', '1985-09-15 00:00:00', '0', '$name', '$email', '', '', '' );";
	echo "<br>";

	mysql_query($query, $conn);
	echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n";

}

fclose($handle);

}


?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 10-30-2006, 09:14 PM
Registered User
 
Join Date: Oct 2006
Posts: 5
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

Can you give me a sample of the csv file? Don't wanna crash the db

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 10-30-2006, 10:46 PM
Registered User
 
Join Date: Oct 2006
Posts: 11
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

csv layout

Name, Email
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 10-30-2006, 11:16 PM
Registered User
 
Join Date: Oct 2006
Posts: 17
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

May seem like a stupid question, but where exactly (in which lines) do I insert username and file?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 10-31-2006, 12:25 AM
Registered User
 
Join Date: Oct 2006
Posts: 11
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

well you will have on your webserver the csv file then you will have

http://yourwebsite.com/cvsupload.php...file=FILE_NAME
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 10-31-2006, 01:57 AM
Registered User
 
Join Date: Oct 2006
Posts: 5
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

link doesn't work :P just quote an exact sample of a csv file you would recommend! only 3 lines...

thanks anyway....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 10-31-2006, 08:12 AM
Registered User
 
Join Date: Oct 2006
Posts: 11
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file


Create a directory on your server called cvsupload.php
upload the cvs file to your server
format is
bob,boobs@boobs.com
chris noen,namit@something.org

create a file called cvsupload.php in the direcotry csv-upload.

find in the sql tables the userid within the roundcube tables then replaec that iin the link below.

replace yourwebsite.com with your website
http://yourwebsite.com/cvsupload.php...file=FILE_NAME
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old 10-31-2006, 08:37 AM
Registered User
 
Join Date: Oct 2006
Posts: 17
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

That didn't work.

Code:
0: user_id (my emailaddress)
file.csvResource id #3
Name: Name Name Email: email
0:
Name: Name Name Email: email
0:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old 10-31-2006, 11:45 AM
Registered User
 
Join Date: Oct 2006
Posts: 5
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

same like me! the script only imports the first 3 contacts and then it stops...

Code:
0: 1
contacts.csvResource id #3
Name: Berlin - Michael Email: michael@berlin.de 
0: 
Name: Dublin - Billy Email: billy@dublin.com 
0: 
Name: Dublin - William Email: william@dublin.com

The output log seems ok, so what else can that be?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old 10-31-2006, 12:19 PM
Registered User
 
Join Date: Oct 2006
Posts: 11
Downloads: 0
Uploads: 0
Default Re: Import address book from csv file

Can you check the sql tables and see if the are being entered?

You also have to logout and then login to roundcube.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

For more information about the ads and why they're here, please see the FAQ

All times are GMT. The time now is 09:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright © 2006-2008 RoundCube Webmail Community