Log in

View Full Version : merging into the gpc array


Nullifi3d
02-16-2008, 04:27 AM
Plugin: profile_updateprofile
I am trying to use $userdata->set to update a custom table field in 'user', however cannot find a way to merge the data with the already existent GPC array. Is this even possible?

Marco van Herwaarden
02-16-2008, 07:08 AM
What do you mean with "merge the data with the already existent GPC array"?

Nullifi3d
02-17-2008, 01:18 AM
I am trying to update two custom fields in the user table when profile data is updated (profile_updateprofile). I want to clean the posted textbox inputs before inserting into the database.

I have in userdata_start:$this->validfields['homepagetitle'] = array(TYPE_STR, REQ_NO);
$this->validfields['homepagedesc'] = array(TYPE_STR, REQ_NO);
And in profile_updateprofile:$vbulletin->input->clean_array_gpc('p', array(
'homepagetitle' => TYPE_STR,
'homepagedesc' => TYPE_STR,
));
$userdata->set('homepagetitle', $vbulletin->GPC['homepagetitle']);
$userdata->set('homepagedesc', $vbulletin->GPC['homepagedesc']);
However, this (obviously) erases the GPC variables already set (other profile info).

Marco van Herwaarden
02-17-2008, 08:28 AM
That code would not empty any GPC variables.

Opserty
02-17-2008, 08:41 AM
Use var_dump() (http://php.net/var_dump) to debug variables if you are having problems. I don't see anything wrong with your code...make sure the data is being sent from the form and is in the $_POST array after you've submitted the form.

Also I suggest that you change 'homepagedesc' & 'homepagetitle' to TYPE_NOHTML to reduce vulnerabilities.

Nullifi3d
02-18-2008, 01:12 AM
I will change to TYPE_NOHTML. Thanks for the advice.

As for the GPC variables, what I meant was when I update my profile, any profile fields other then 'homepagetitle' and 'homepagedesc' are not set because $vbulletin->input->clean_array_gpc('p', array(
'homepagetitle' => TYPE_STR,
'homepagedesc' => TYPE_STR,
)); is called (within the plugin profile_updateprofile) which is executed in profile.php after: $vbulletin->input->clean_array_gpc('p', array(
// coppa stuff
'coppauser' => TYPE_BOOL,
'parentemail' => TYPE_STR,
// IM handles / homepage
'aim' => TYPE_STR,
'yahoo' => TYPE_STR,
'icq' => TYPE_STR,
'msn' => TYPE_STR,
'skype' => TYPE_STR,
'homepage' => TYPE_STR,
// user title
'resettitle' => TYPE_STR,
'customtext' => TYPE_STR,
// birthday fields
'day' => TYPE_INT,
'month' => TYPE_INT,
'year' => TYPE_INT,
'oldbirthday' => TYPE_STR,
'showbirthday' => TYPE_UINT,
// redirect button
'gotopassword' => TYPE_NOCLEAN,
// custom profile fields
'userfield' => TYPE_ARRAY,
));

Marco van Herwaarden
02-18-2008, 06:39 AM
Sorry but i still dont understand what you mean. Using clean_array_gpc() does not empty previously set variables.

Nullifi3d
02-19-2008, 02:25 AM
/me is retarded

To test my plugin I was entering 'home page url' as the data for the homepage field and other strings for the custom fields I made. It just came to me that homepage was not updating because I was not inputing a valid url. Don't ya hate thinking deeper then you have to?