1
hiflyer
Xoops (User) Importer
  • 2010/10/22 2:38

  • hiflyer

  • Not too shy to talk

  • Posts: 107

  • Since: 2006/3/7 3


Ted Smith wrote a module XoopsImporterhttps://xoops.org/modules/news/article.php?storyid=2969 that was very handy but apparently doesn't work with the new user database for 2.4
Any chance anyone can update this? I assume just the code below needs to be updated.
I would also love the option to define a Group for each user.

// Get the data from import file----------------------------------------------------------------------------------------

echo ("Beginning file import process...(scroll to bottom to see all results and confirmation) <br /> <br />");
$count 0;
  while (!
feof($InputFileExists))                                  //Start of While Loop
  
{
    
$GetData fgets($InputFileExists,4096);                      // Get data and place in array 4096 bytes per slot
       
$count++;
    
$ArraySlots explode("$charDeliminationCharacter",$GetData); // Define the array and 
    
$Username $ArraySlots[0];                                     // 1st column from input file
    
$RealName $ArraySlots[1];                                      // 2nd column from input file
    
$Email $ArraySlots[2];                                       // 3rd column from input file
    
$URL $ArraySlots[3];                                          // 4th column from input file
    
$ICQ $ArraySlots[4];                                          // 5th column from input file
    
$AIM $ArraySlots[5];                                          // 6th column from input file
    
$YIM $ArraySlots[6];                                          // 7th column from input file
    
$MSNM $ArraySlots[7];                                          // 8th column from input file
    
$Location $ArraySlots[8];                                      // 9th column from input file
    
$Signature $ArraySlots[9];                                  // 10h column from input file
    
$Occupation $ArraySlots[10];                                  // 11th column from input file
    
$Interest $ArraySlots[11];                                  // 12th column from input file
    
$ExtraInfo $ArraySlots[12];                                  // 13th column from input file
    
$Password sprintf("%sn",md5($ArraySlots[13]));               // 14th column from input file - Calc the MD5 value and store
  
    // Insert all the values from input file into the database ---------------------------------------------------------------

    
$xoops_usersVar = ($strDatabaseXoopsPrefix.'users');     // Assign value of DB prefix for entry into 'DBprefix_users' table

    
$query "INSERT INTO $xoops_usersVar  (uname, name, email, url, user_icq, user_aim, user_yim, user_msnm, user_from, user_sig, user_occ, user_intrest, bio, pass) VALUES ('$Username','$RealName','$Email','$URL','$ICQ','$AIM','$YIM','$MSNM','$Location','$Signature','$Occupation','$Interest','$ExtraInfo','$Password')";

      
$result mysql_query($query);
      
$uid mysql_insert_id();
         if (
mysql_error())
         {
          echo 
"There's an error in the database : ".mysql_error();
          echo 
"<br>Sorry, import process aborted. Please examine the error and re-try";
          
fclose($InputFileExists);
          
mysql_close($sqlconnection);
          exit();
         }

    
//Increment the UserID starting from the last User ID (detects last ID and autoincrements.)For each entry, display the result on the screen until EOF is reached. ------------------------------------------------ 
    
$Groups_Users_LinkVar = ($strDatabaseXoopsPrefix.'groups_users_link');
    
    
$numgroup '2';           
      
$insertvalues "INSERT INTO $Groups_Users_LinkVar (groupid, uid) VALUES('$numgroup', '$uid')";
      
$resultmysql_query($insertvalues);
        if (
mysql_error())
         {
         echo 
"There's an error in the database : ".mysql_error();
         echo 
"<br>Sorry, import process aborted. Please examine the error and re-try";
            
fclose($InputFileExists);
            
mysql_close($sqlconnection);
            exit();
         }
         else 
         {
           echo 
"Username ".$Username." imported OK, ID - ".$uid." <br /> "
         }
  }  
//End of While loop


Thanks!!

2
ghia
Re: Xoops (User) Importer
  • 2010/10/22 6:05

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


See also this script, which I suppose will still run.

Login

Who's Online

150 user(s) are online (91 user(s) are browsing Support Forums)


Members: 0


Guests: 150


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits