I successfully imported customers from a CSV from an old database that stored passwords in plain text.
This will put them in CRE Loaded using encryption.
1) First off, make sure db.php has your database connection/selection info.
2) $plaintext = $data[3];
Change 3 to whichever column has the password. Keep in mind the first column is 0, so 3 would be the 4th column.
3) You can add/remove columns from the statement below.
You may want to add customers_validation with a value of '1' and customers_account_approval with a value of "Approve" if you're importing valid customers.
For me, data[0] was the customers_id. If your CSV doesn't have this, you may want to add it. Just make sure you don't overwrite existing customers' customers_id. Check phpMyAdmin for the last entry.
There is an autonumber function in Excel that you can paste into the cells. I think you can paste into all selected cells at once, so you don't have to paste a thousand times.
Without this column, you will probably need to look into mysql_insert_id().
$import="INSERT IGNORE INTO customers(customers_id,customers_firstname,customers_lastname,customers_password,customers_email_address,customers_email_registered,customers_group_id) values('$data[0]','$data[1]','$data[2]','$password','$data[4]','$data[4]','$data[6]')";
4) Make sure the customers_info_id value matches the previous statement.
$import2="INSERT IGNORE INTO customers_info(customers_info_id) values('$data[0]')";
5) Create a directory & chmod it to 777. In my example, I used 'temp'. Make sure the path is correct.
uploader.phpCode:
<?php
include("db.php");
// Return a random value
function tep_rand($min = null, $max = null) {
static $seeded;
if (!isset($seeded)) {
mt_srand((double)microtime()*1000000);
$seeded = true;
}
if (isset($min) && isset($max)) {
if ($min >= $max) {
return $min;
} else {
return mt_rand($min, $max);
}
} else {
return mt_rand();
}
}
// Upload/Import stuff
if(!isset($_POST['submit'])){
$message = "<table align=center><tr><td width=18><img align=left src=\"images/info.gif\"></td><td><b>Please select a file to import.</b></td></tr></table>";
} else {
$target_path = "temp/";
$target_path = $target_path . basename( $_FILES['csv_file']['name']);
if(move_uploaded_file($_FILES['csv_file']['tmp_name'], $target_path)) {
$message = "<img src=\"images/check.gif\"> The file <b>" . basename( $_FILES['csv_file']['name']) . "</b> has been imported if there are no errors below.";
// Read the CSV file, and import into database
$filename=$target_path . $_POST['csv_file'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){
if($data[0] != null){
// encrypt password
$plaintext = $data[3];
$password = '';
for ($i=0; $i<10; $i++) {
$password .= tep_rand();
}
$salt = substr(md5($password), 0, 2);
$password = md5($salt . $plaintext) . ':' . $salt;
// end password encryption
$import="INSERT IGNORE INTO customers(customers_id,customers_firstname,customers_lastname,customers_password,customers_email_address,customers_email_registered,customers_group_id) values('$data[0]','$data[1]','$data[2]','$password','$data[4]','$data[4]','$data[6]')";
$import2="INSERT IGNORE INTO customers_info(customers_info_id) values('$data[0]')";
}
mysql_query($import) or die(mysql_error());
mysql_query($import2) or die(mysql_error());
}
fclose($handle);
// If something is wrong with the file, let them know.
} else {
$message = "<span style=\"color:#FF0000;\">There was an error uploading the file, please try again!</span>";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSV Uploader</title>
<link rel="stylesheet" href="uploader.css" type="text/css">
</head>
<body>
<h1> Import Customers </h1>
<form method="post" enctype="multipart/form-data">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><br>
<div class="message" align="center"><?php echo $message; ?></div>
<br>
<br>
Select the list (CSV) you would like to import.<br>
<br>
<input type="file" name="csv_file">
<br>
<span style="font-size:10px; font-weight:bold;">CSV files only. Max file size: 5mb.</span><br>
<br> <input type="submit" name="submit" value="Import List">
</td>
</tr>
</table>
</form>
</body>
</html>
Feel free to add more statements to write to other tables if needed. Thankfully I only needed the 2

I was in a hurry when I wrote the instructions, so let me know if it needs clarification.