1
tdldp
[ PB V2 ] Adding user data to DB fields within activation key process
  • 2004/1/19 10:57

  • tdldp

  • Just popping in

  • Posts: 9

  • Since: 2002/3/13


Hi all, i am meeting a problem using XOOPS for a future company site.

I wish at the activation stage (for memory, a mail has been sent to user, with an activation key link), that some data gets added to the xoops_user table in 3 fields.

I have noticed that in kernel/member.php, the activation process updates the "level" field, making it pass from 0 (not activated) to 1 (activated)
At this update, i wish that the following fields get updated invisibly for the user :
- date field, activated date in datetime format 0000-00-00 00:00:00
- ip field : ip adress at activation process
- valide field, value 1 in replacement of 0.

I have modified the validate function in kernel/member.php so that it looks like this :

Quote:

function activateUser(&$user)
{
$dateus = date("Y-m-d");
$heure = date("H:i:s");
$lejour = "$dateus "."$heure";
if ($user->getVar('level') != 0) {
return true;
}
$user->setVar('level', 1);

if ($user->getVar('valide') != 0) {
return true;
}
$user->setVar('valide', 1);

if ($user->getVar('date') != 0) {
return true;
}
$user->setVar('date', $lejour);

if ($user->getVar('ip') != 0) {
return true;
}
$user->setVar('ip', $REMOTE_ADDR);
return $this->_uHandler->insert($user, true);
}

And here is old file
Quote:

function activateUser(&$user)
{
if ($user->getVar('level') != 0) {
return true;
}
$user->setVar('level', 1);
return $this->_uHandler->insert($user, true);
}



Apparently it doesn't work and i can't see why.
For update security i also modified Kernel/user.php the function insert as follows :

Quote:

function insert(&$user, $force = false)
{
if (get_class($user) != 'xoopsuser') {
return false;
}
if (!$user->isDirty()) {
return true;
}
if (!$user->cleanVars()) {
return false;
}
foreach ($user->cleanVars as $k => $v) {
${$k} = $v;
}
// RMV-NOTIFY
// Added two fields, notify_method, notify_mode
if ($user->isNew()) {
$uid = $this->db->genId($this->db->prefix('users').'_uid_seq');
$sql = sprintf("INSERT INTO %s (uid, uname, name, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank, level, theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok, date, ip, prenom, dept, type, mailing, valide) VALUES (%u, %s, %s, %s, %s, %s, %u, %s, %s, %s, %u, %s, %s, %s, %s, %s, %u, %u, %u, %u, %s, %.2f, %u, %s, %u, %u, %u, %s, %s, %s, %u, %u, %u, %s, %u, %u, %u, %u)", $this->db->prefix('users'), $uid, $this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), time(), $this->db->quoteString($user_icq), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail, $this->db->quoteString($actkey), $this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $this->db->quoteString($pass), $posts, $attachsig, $rank, $level, $this->db->quoteString($theme), $timezone_offset, 0, $this->db->quoteString($umode), $uorder, $notify_method, $notify_mode, $this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok, $date, $ip, $this->db->quoteString($prenom), $dept, $type, $mailing, $valide);
} else {
$sql = sprintf("UPDATE %s SET uname = %s, name = %s, email = %s, url = %s, user_avatar = %s, user_icq = %s, user_from = %s, user_sig = %s, user_viewemail = %u, user_aim = %s, user_yim = %s, user_msnm = %s, posts = %d, pass = %s, attachsig = %u, rank = %u, level= %u, theme = %s, timezone_offset = %.2f, umode = %s, last_login = %u, uorder = %u, notify_method = %u, notify_mode = %u, user_occ = %s, bio = %s, user_intrest = %s, user_mailok = %u, date = %u, ip = %u, prenom = %s, dept = %u, type = %u, mailing = %u, valide = %u WHERE uid = %u", $this->db->prefix('users'), $this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), $this->db->quoteString($user_icq), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail, $this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $posts, $this->db->quoteString($pass), $attachsig, $rank, $level, $this->db->quoteString($theme), $timezone_offset, $this->db->quoteString($umode), $last_login, $uorder, $notify_method, $notify_mode, $this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok, $date, $ip, $this->db->quoteString($prenom), $dept, $type, $mailing, $valide, $uid);
}
if (false != $force) {
$result = $this->db->queryF($sql);
} else {
$result = $this->db->query($sql);
}
if (!$result) {
return false;
}
if (empty($uid)) {
$uid = $this->db->getInsertId();
}
$user->assignVar('uid', $uid);
return true;
}




I am not searching a full made solution, if people has an idea of the problem i am facing, any help will be appreciated

Thanks
Tdldp

2
tdldp
Re: [ PB V2 ] Adding user data to DB fields within activation key process
  • 2004/1/20 8:41

  • tdldp

  • Just popping in

  • Posts: 9

  • Since: 2002/3/13


i have managed to obtain partial success in my requirements....

Valide is updated correctly.... from 0 to 1...
Date is updated on DB, but wrong date is inserted
IP is updated on DB but only the first part of adress (xx.XX.XX.XX only xx is inserted)

I have placed variable controls in activate function, which provide me the right data, but this data is not inserted in Database correctly
script is now the following :

function activateUser(&$user)
{
if ($user->getVar('level') != 0) {
return true;
}
$user->setVar('level', 1);
$user->setVar('valide', 1);
$ip_text = getenv(REMOTE_ADDR);
$dateus = date("Y-m-d");
$heure = date("H:i:s");
$lejour = "$dateus "."$heure";
echo "Variable date :".$lejour;
echo "Variable ip :".$ip_text;
$user->setVar('date', $lejour);
$user->setVar('ip', $ip_text);
return $this->_uHandler->insert($user, true);
}


I am wondering if the problem doesn't come from he kernel/user.php definitions :

I use for ip and date :

$this->initVar('date', XOBJ_DTYPE_OTHER, 0, false);
$this->initVar('ip', XOBJ_DTYPE_TXTBOX, 0, false, 64);


and i wonder if these are the right ones...

By the way i have not found any documentation on these XOBJ_DTYPE_XXX things... In particular, what are the different types accepted, and what are their variables...

If any of you can bring me help, it would be grandly appreciated... And if devs could answer my XOBJ question, i'd appreciate...

Tdldp

3
tdldp
Re: [ PB V2 ] Adding user data to DB fields within activation key process
  • 2004/1/20 16:11

  • tdldp

  • Just popping in

  • Posts: 9

  • Since: 2002/3/13


UP it goes.... No one can give me an advice ??? i've been trying myself allday on code, and havent found solution yet ...

PLease devs, do answer my question on defining those Xobjtype... it could help me a bit....

Login

Who's Online

437 user(s) are online (344 user(s) are browsing Support Forums)


Members: 0


Guests: 437


more...

Donat-O-Meter

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

Latest GitHub Commits