X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Importing existing Users List (https://forum.x-cart.com/showthread.php?t=734)

Getcarter 11-21-2002 03:39 PM

Importing existing Users List
 
Hi guys,
I have a user list of about 400 dealers and would like to import them into the databse...

any ideas how i can do this? :roll:

if anyone can help will be great, i'm using phpMyadmin to manage the db.

thanks!

funkydunk 11-22-2002 12:12 AM

Re: Importing existing Users List
 
Quote:

Originally Posted by Getcarter
Hi guys,
I have a user list of about 400 dealers and would like to import them into the databse...

any ideas how i can do this? :roll:

if anyone can help will be great, i'm using phpMyadmin to manage the db.

thanks!


The table in x-cart is xcart_customers.

The hard part will be putting the password into the table so that it will work - is it an existing x-cart dealer list?

If so, if you export the data from the existing table using phpmyadmin and then simply import the sql into the new table.

If it isn't.... a lot of work is needed to encrypt the password that you have in a flat file to get them into the database.

The function in xcarts func.php script is:

Code:

function text_crypt($s) {
    global $START_CHAR_CODE, $CRYPT_SALT;

    if ($s == "")
        return $s;
    $enc = rand(1,255); # generate random salt.
    $result = text_crypt_symbol($enc); # include salt in the result;
    $enc ^= $CRYPT_SALT;
    for ($i = 0; $i < strlen($s); $i++) {
        $r = ord(substr($s, $i, 1)) ^ $enc++;
        if ($enc > 255)
            $enc = 0;
        $result .= text_crypt_symbol($r);
    }
    return $result;
}


Now in theory it should be possible to run each name in your list through this function and then add it to the table.

Enjoy !! :wink:

Funkydunk

Getcarter 11-22-2002 09:24 PM

thanks
 
Hi there,

thanks for the quick reply, unfortunately the list of users is from another cart. i have been exporting the users list from xcel to txt then importing to the previous cart...

i figured the encryption will be a prob, but i'll give it a try. Was hoping that someone had this experience before...

thanks again,
GC :D

funkydunk 11-22-2002 11:23 PM

Afraid I haven't got the experience of doing this with x-cart but if you can code a bit in php, you will be able to get it to open your file of the dealer list and loop through each item, encrypting the password, then adding it to the table in x-cart.

If you want help with the code let me know.

Funkydunk

ryan 12-04-2002 10:02 AM

I had them customize this for me. In the SQL string the password part just has:

Code:

password='".text_crypt($columns[6])."'

If you want I can send you the whole file.

What I need to do is have the password exported with the order our of xcart so I can import it into my accounting system.

mark_d 03-02-2004 12:36 PM

a possible solutuion
 
Some had this posted a while back - SOMEHOW this import post was deleted - Humm??

anyway heres the code:

Code:

?php

// check path to xcart/include/func.php file

include "../estore/include/func.php";

# SALT & CODE for user password & credit card encryption
# take it from your xcart/config.php file

$CRYPT_SALT = 85; # any number ranging 1-255
$START_CHAR_CODE = 100; # 'd' letter

// import from file

$myfile = file("customer.txt");

// MySQL Server Info

$sql_host ='SQL_server';
$sql_user ='username';
$sql_db ='database_name';
$sql_password ='password';

$customers_table = 'xcart_customers';
$maillist_table = 'xcart_maillist';


// create connection to MySQL server
@mysql_pconnect($sql_host,$sql_user,$sql_password) or die("Couldn't make connection.");

// select the database
@mysql_select_db($sql_db) or die("Couldn't select $database database.");


for ($index=0; $index < count($myfile); $index++)
  {

  $new_subs = split("\  ", chop($myfile[$index]));

// import file structure can be different in your case

//  $email      =$new_subs[0];
//  $password      =text_crypt($new_subs[1]);
//  $b_firstname  =ucwords($new_subs[2]);
//  $b_lastname      =ucwords($new_subs[3]);
//  $b_company      =ucwords($new_subs[4]);
//  $b_addr      =ucwords($new_subs[5]);
//  $b_addr2      =ucwords($new_subs[6]);
//  $b_city      =ucwords($new_subs[7]);
//  $b_state      =$new_subs[8];
//  $b_zipcode      =$new_subs[9];
//  $b_phone      =$new_subs[10];
//  $s_name      =ucwords($new_subs[11]);
//  $s_company      =ucwords($new_subs[12]);
//  $s_addr      =$new_subs[13];
//  $s_addr2      =$new_subs[14];
//  $s_city      =ucwords($new_subs[15]);
//  $s_state      =$new_subs[16];
//  $s_zipcode      =$new_subs[17];
//  $s_phone      =$new_subs[18];
//  $login                =ucwords($new_subs[19]);
//  $member_type        =ucwords($new_subs[20]);
//  $use_lang        =ucwords($new_subs[21]);
//  $fax                        =$new_subs[22];
//
//
  $login                =ucwords($new_subs[0]);
  $usertype        =ucwords($new_subs[1]);
  $membership        =$new_subs[2];
  $password      =text_crypt($new_subs[3]);
  $password_hint      =$new_subs[4];
  $password_hint_answer      =$new_subs[5];
  $b_address      =ucwords($new_subs[6]);
  $b_address2      =ucwords($new_subs[7]);
  $b_city      =ucwords($new_subs[8]);
  $b_state      =$new_subs[9];
  $b_country    =$new_subs[10];
  $b_zipcode      =$new_subs[11];
  $title      =$new_subs[12];
  $firstname  =ucwords($new_subs[13]);
  $lastname      =ucwords($new_subs[14]);
  $position  =ucwords($new_subs[15]);
  $company      =$new_subs[16];
  $s_contact      =$new_subs[17];
  $s_address      =ucwords($new_subs[18]);
  $s_address2      =ucwords($new_subs[19]);
  $s_city      =ucwords($new_subs[20]);
  $s_state      =$new_subs[21];
  $s_country    =$new_subs[22];
  $s_zipcode      =$new_subs[23];
  $email      =$new_subs[24];
  $s_email      =$new_subs[25];
  $phone      =$new_subs[26];
  $s_phone      =$new_subs[27];
  $fax      =$new_subs[28];
  $s_fax      =$new_subs[29];
  $url      =$new_subs[30];
  $card_name      =$new_subs[31];
  $card_type      =$new_subs[32];
  $card_number      =text_crypt($new_subs[33]);
  $card_expire      =$new_subs[34];
  $card_cvv2      =$new_subs[35];
  $last_login      =$new_subs[36];
  $first_login      =$new_subs[37];
  $status      =$new_subs[38];
  $referer      =$new_subs[39];
  $pending_membership      =$new_subs[40];
  $ssn      =$new_subs[41];
  $tax_id      =$new_subs[42];
  $language      =ucwords($new_subs[43]);


/**
// i used this for testing before import

  echo $login." ";
  echo $usertype." ";
  echo $membership." ";
  echo $password." ";
  echo $password_hint." ";
  echo $password_hint_answer." ";
  echo $b_address." ";
  echo $b_address2." ";
  echo $b_city." ";
  echo $b_state." ";
  echo $b_country." ";
  echo $b_zipcode." ";
  echo $title." ";
  echo $firstname." ";
  echo $lastname." ";
  echo $b_position." ";
  echo $company." ";
  echo $s_address." ";
  echo $s_address2." ";
  echo $s_city." ";
  echo $s_state." ";
  echo $s_ccountry." ";
  echo $s_zipcode." ";
  echo $email." ";
  echo $s_email." ";
  echo $phone." ";
  echo $s_phone." ";
  echo $s_name." ";
  echo $fax." ";
  echo $s_fax." ";
  echo $url." ";
  echo $card_name." ";
  echo $card_type." ";
  echo $card_number." ";
  echo $card_expire." ";
  echo $card_cvv2." ";
  echo $last_login." ";
  echo $first_login." ";
  echo $status." ";
  echo $referer." ";
  echo $pedning_membership." ";
  echo $ssn." ";
  echo $tax_id." ";
  echo $language." ";
  echo "
";
**/

add_user($login, $usertype, $membership, $password, $password_hint, $password_hint_answer, $b_address, $b_address2, $b_city, $b_state, $b_country, $b_zipcode, $title, $firstname, $lastname, $b_position, $company, $s_contact, $s_address, $s_address2, $s_city, $s_state, $s_country, $ $s_zipcode, $email, $s_email, $phone, $s_phone, $fax, $s_fax, $url, $card_name, $card_type, $card_number, $card_expire, $card_cvv2, $last_login, $first_login, $status, $referer, $pending_membership, $ssn, $tax_id, $language);

  }

// close database

mysql_close();

echo "<h1>Import was completed!</h1>";

exit;


function add_user($login, $usertype, $membership, $password, $password_hint, $password_hint_answer, $b_address, $b_address2, $b_city, $b_state, $b_country, $b_zipcode, $title, $firstname, $lastname, $b_position, $company, $s_contact, $s_address, $s_address2, $s_city, $s_state, $s_country, $s_zipcode, $email, $s_email, $phone, $s_phone, $fax, $s_fax, $url, $card_name, $card_type, $card_number, $card_expire, $card_cvv2, $last_login, $first_login, $status, $referer, $pending_membership, $ssn, $tax_id, $language)
{

GLOBAL $customers_table, $maillist_table;

  $query = "INSERT INTO $customers_table (login, usertype, membership, password, password_hint, password_hint_answer, b_address, b_address2, b_city, b_state, b_country, b_zipcode, title, firstname, lastname, b_position, company, s_contact, s_address, s_address2, s_city, s_state, s_country, s_zipcode, email, s_email, phone, s_phone, fax, s_fax, url, card_name, card_type, card_number, card_expire, card_cvv2, last_login, first_login, status, referer, pending_membership, ssn, tax_id, language) VALUES (\"$login\", \"$usertype\", \"$membership\", \"$password\", \"$password_hint\", \"$password_hint_answer\", \"$b_address\", \"$b_address2\", \"$b_city\", \"$b_state\", \"$b_country\", \"$b_zipcode\", \ "$title\", \"$firstname\", \"$lastname\", \"$b_position\", \"$company\", \"$s_contact\", \"$s_address\", \"$s_address2\", \"$s_city\", \"$s_state\", \"$s_country\", \"$s_zipcode\", \"$email\", \"$s_email\", \"$phone\", \"$s_phone\", \"$fax\", \"$s_fax\", \"$url\", \"$card_name\", \"$card_type\", \"$card_number\", \"$card_expire\", \"$card_cvv2\", \"$last_login\", \"$first_login\", \"$status\", \"$referer\", \"$pending_membership\", \"$ssn\", \"$tax_id\", \"$language\")";
  $result = @mysql_query($query)
      or print("
Couldn't add user: ".$email);

  $query = "INSERT INTO $maillist_table (email, since_date) VALUES (\"$email\", \"$first_login\")";
  $result = @mysql_query($query)
      or print("
Couldn't add email: ".$email);

  $query = "INSERT INTO $maillist_table (s_email, since_date) VALUES (\"$s_email\", \"$first_login\")";
  $result = @mysql_query($query)
      or print("
Couldn't add email: ".$s_email);


} // add_user


?>


Now - I have added several EXTRA FIELDS which is a different mod altogether. But this is the concept....

The fields added are for ship to additional info - like phone, fax, email - so I changed the code to add the second email to the email list table.

IT WORKS - BUT - the delimiter for the input file is a problem for me. several fields will be entered into 1 MySQL table field.

Im no coder but i know enough to be a pain in the A$$. :wink:
I cant remember what file type to use for import... any help here?

mark_d 03-03-2004 06:00 AM

my bad :?

that original thread was here
http://forum.x-cart.com/viewtopic.php?t=2972


- but no explaination of input file format.

any one?

rcci@mindspring.com 09-26-2005 06:48 AM

Has anyone done this in the 4.x area? I'm importing several hundred customers from a custom-written ASP cart, and the passwords and credit card numbers are in clear text. I need to encrypt them, but don't have the level of PHP skills to write the code to do so.

I have used PHPMyAdmin to retrieve the datafile into a delimited text file, and can re-insert the data into x-cart, but I need to process it first.

Has anyone out there done this and are you willing to share your code? I'm tapped out of cash for paying X-cart, the mods I had to get done for adding mixed discounts and shipping markups based on quantity and restricted shipping to only listed states ate what little budget I had...and we're *so* close to launch....

Thanks for any input. Honestly, I've learned *so* much just reading what y'all have posted, I don't think I would have gotten my cart working so well if it weren't for these forums!

Hmm, found this: http://forum.x-cart.com/viewtopic.php?t=2972&highlight=encryption. The code here looks pretty straightforward. Is it ok for 4.013?

Thanks!


All times are GMT -8. The time now is 05:38 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.