Last updated December 5, 2009. Created by Suuch on December 27, 2005.
Edited by ermalhack, sepeck. Log in to edit this page.

This hack has two pieces and is meant to be temporary. It makes the fact of the migration transparent to regular users. Revert to the default user.module after you notice that most of your regular users have visited your site. Everyone else can use the "request password reminder" feature to reset their passwords.

First is this file: dcuser.inc which just defines some basic functions required to encrypt dcuser passwords.

<?php
function my_crypt($str,$salt) {
   return
crypt($str,substr($salt,0,2));
}
function
check($username)
{
   
$q = "SELECT *
           FROM
$my_dcf_dbase.dcuser
          WHERE username = '
$username' ";
  
$result = mysql_query($q) or die(mysql_error());
   if (!
mysql_num_rows($result))
   {
     
$error = $in['lang']['no_such_user'];
   }
   else
   {
     
$row = mysql_fetch_array($result);
     
$in['last_date'] = $row['last_date'];
      if (
$row['status'] != 'on')
      {
        
$error "Deactivated account";
      }
    }
    return
$row['password'];
}
?>

And then in user.module replace user_load with the following(remember to replace $my_dcf_dbase with the actual name of your dcf mysql database):

<?php
function user_load($array = array()) {
// dcforum+ migration user.module hack: start
include_once("dcforum/dcuser.inc"); //assuming that dcuser.inc is in modules/dcforum
if(($array['name'] != ""))
{
   
$dcpass = my_crypt($array['pass'], check($array['name']));
   
$dcuser = db_fetch_array(db_query("SELECT id, username, password, g_id FROM $my_dcf_dbase.dcuser WHERE username='%s' AND password='%s'", $array['name'], $dcpass));
    if((
sizeof($dcuser) > 0) && ($dcuser['g_id'] > 0)) //valid dcuser!
   
{ //copy password into drupal database if not changed.
       
$drpass = db_result(db_query("SELECT pass FROM {users} WHERE name='%s'", $array['name']));
        if(
$drpass != md5($array['pass']))
        {
           
db_query("UPDATE {users} SET pass='%s' WHERE name='%s'", md5($array['pass']), $array['name']);
        }
    }
}
// dcforum+ migration user.module hack: end
  // Dynamically compose a SQL query:
 
$query = '';
 
$params = array();
  foreach (
$array as $key => $value) {
    if (
$key == 'pass') {
     
$query .= "u.pass = '%s' AND ";
     
$params[] = md5($value);
    }
    else if (
$key == 'uid') {
     
$query .= "u.uid = %d AND ";
     
$params[] = $value;
    }
    else {
     
$query .= "LOWER(u.$key) = '%s' AND ";
     
$params[] = strtolower($value);
    }
  }
 
$result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", $params, 0, 1);
  if (
db_num_rows($result)) {
   
$user = db_fetch_object($result);
   
$user = drupal_unpack($user);
   
$user->roles = array();
   
$result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
    while (
$role = db_fetch_object($result)) {
     
$user->roles[$role->rid] = $role->name;
    }
   
user_module_invoke('load', $array, $user);
  }
  else {
   
$user = new StdClass();
  }
  return
$user;
}
?>

W32/TrojanDownloader.Ani.Gen

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.