Thread: Import Users
View Single Post
  #1  
Old 15th March 2008, 04:35
Fynnon's Avatar
Fynnon Fynnon is offline
xxx
 
Join Date: Nov 2007
P2P
Posts: 984
Angry Import Users
This script is working 100%

i tested it and you can import the users and users don't even have to recover the pass

This code is very useful when you try to change from one source to another i did it

my friend wanted to change from X*m to Tbdev and it worked fine

Note: All Thanks goes to Aurthor of this code

use this

import.php
Code:
<?php
require_once("include/bittorrent.php");
dbconn();

# Table Names
$old_tableprefix = "users2"; // Old table name
$new_tableprefix = "users"; //New Table Name

#$query = do_mysql_query("SELECT id, username, email, added, secret, passhash, uploaded, downloaded, donor, gender, country, vip_until FROM {$old_tableprefix}") or sqlerr(__FILE__,__LINE__);
$query = do_mysql_query("SELECT id, username, email, added, secret, passhash, uploaded, downloaded, gender, status FROM {$old_tableprefix}") or sqlerr(__FILE__,__LINE__);

stdhead();
echo "I will try to update user table --> ";
$count=0;
while ($olduser = mysql_fetch_assoc($query))
{
  //  $id = intval($olduser['id']);
  //  if ($id == 1)
   //     $class = UC_SYSOP;
  //  else
      //  $class = UC_USER;

    $id = sqlesc($olduser['id']);
    $username = sqlesc($olduser['username']);
    $passhash = sqlesc($olduser['passhash']);
    $secret = sqlesc($olduser['secret']);
    $email = sqlesc($olduser['email']);
    $added = sqlesc($olduser['added']);
    $uploaded = sqlesc($olduser['uploaded']);
    $downloaded = sqlesc($olduser['downloaded']);
   // $donor = sqlesc($olduser['donor']);
    $gender = sqlesc($olduser['gender']);
    $status = sqlesc($olduser['status']);
  //  $country = sqlesc($olduser['country']);
  //  $donoruntil = sqlesc($olduser['vip_until']);
    

    
  /*  do_mysql_query("INSERT INTO {$new_tableprefix} (id,username,email,passhash,secret,added,uploaded,downloaded,donor,gender,countr
y,donoruntil) 
    VALUES ($id, $username, $email, $passhash, $secret, $added, $uploaded, $downloaded, $donor, $gender, $country, $donoruntil)");
    $count++;
}   */

do_mysql_query("INSERT INTO {$new_tableprefix} (id,username,email,passhash,secret,added,uploaded,downloaded,gender,status) 
    VALUES ($id, $username, $email, $passhash, $secret, $added, $uploaded, $downloaded, $gender, $status)");
    $count++;
}

echo "Done..

Total {$count} users has been updaded...
Note: All users should recover their password...";
stdfoot();
?>
then run this SQL queries (phpmyadmin)
Because it will not import passkey [ its not added in importing code]

Code:
UPDATE users SET passkey=md5(passhash);
should work Fine

If can make this code better please do so and some feedback :D

Update:

you can also try this SQL queries

Code:
INSERT INTO users (field1, field2, field3, field4)
SELECT field1, field2, field3, field4 FROM users3
or

Code:
REPLACE INTO users (field1, field2, field3, field4)
SELECT field1, field2, field3, field4 FROM users3
Thx

Sam007@tbdev.net
Reply With Quote
The Following 2 Users Say Thank You to Fynnon For This Useful Post:
nicukent (27th January 2010), Tibys08 (29th May 2011)