Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 09-04-2006, 01:14 PM
hsomel hsomel is offline
 
Join Date: Aug 2006
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Deleting Users via the Data manager

Hi,

I am trying to delete VB user via one of my php scripts, using the following code:
Code:
function qpc_post($varname)
{
	return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}

require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');

/* get user id of specifed username */
$array = $db->query_first("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username='" . qpc_post('username') . "'");

$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);

$userdm->set_existing(fetch_userinfo($array['userid']));

$userdm->delete();
As you can see the username of the user to be deleted is posted to this script using CURL, then I get the userID of that user and create a new user datamanager to store the details for this user. Then I set the userdm to hold the details of this existing user using fetch_userinfo.

Then to delete the user I simply call the delete() method. This code deletes the user as when i check in the admin cp the user account has gone however I still get the following error (deleteVBUser.php my php script):

Fatal error: Existing data passed is not an array
Called set_existing in /usr/local/apache/htdocs/forums/deleteVBUser.php on line 22
in /includes/class_dm.php on line 235

Any ideas on what this means? Am I doing something wrong?

Your help would be much appreciated.

Thanks
Reply With Quote
  #2  
Old 09-04-2006, 01:17 PM
Wild-Wing Wild-Wing is offline
 
Join Date: Dec 2005
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

take a look at the user dm class ill get back to you about this in one sec i just need to find a hack file.

PHP Code:
if ($info['userid'] == $vbulletin->GPC['userid'])
            {
                
$userdm =& datamanager_init('User'$vbulletinERRTYPE_CP);
                
$userdm->set_existing($info);
                
$userdm->delete();
                unset(
$userdm); 
i think you can get the jist of it
Reply With Quote
  #3  
Old 09-04-2006, 01:41 PM
hsomel hsomel is offline
 
Join Date: Aug 2006
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

Thanks for the quick response. I have modified my code so that it matches the your example but I am still getting the same error:

Fatal error: Existing data passed is not an array
Called set_existing in /usr/local/apache/htdocs/forums/deleteVBUser.php on line 23
in /includes/class_dm.php on line 235

Can the delete method be called in the manner which I am trying?

Or Is it because I am using the function fetch_userinfo to set the existing contents of a user data manager?

Thanks

Hi

I think the error I am getting relates to the following code, which can be found in includes/class_dm_user.php (line 1795):

Code:
$admindm =& datamanager_init('Admin', $this->registry, ERRTYPE_SILENT);
$admindm->set_existing($this->existing);
$admindm->delete();
unset($admindm);

In the above code it seems to initiate a admin datamanager and then tries to delete it, is this right?

I am trying to delete users who may not have logged into the forums, is this possible? Or can you only delete users who have logged in?

Thanks
Reply With Quote
  #4  
Old 09-04-2006, 02:18 PM
Wild-Wing Wild-Wing is offline
 
Join Date: Dec 2005
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you might need to add this in require_once(DIR . '/includes/adminfunctions.php');
Reply With Quote
  #5  
Old 09-04-2006, 02:25 PM
hsomel hsomel is offline
 
Join Date: Aug 2006
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

Again thanks for the quick response!

added the following include :

require_once(DIR . '/includes/adminfunctions.php');

But I still get the same error. The really strange thing is that it deletes the user but still displays the error message. As I said in my previous post it seems initialise an admin datamanager, I dont understand why it does this!?

Thanks
Reply With Quote
  #6  
Old 09-04-2006, 02:28 PM
Wild-Wing Wild-Wing is offline
 
Join Date: Dec 2005
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i just found this // Do the account deletion
$info = fetch_userinfo($vbulletin->GPC['userid']);

also use unset($userdm); after the first code i gave you
Reply With Quote
  #7  
Old 09-04-2006, 02:41 PM
hsomel hsomel is offline
 
Join Date: Aug 2006
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

Nope that didnt work still get the same error message!

Regarding the code that you listed in your last post am I correct in assuming that it would only delete the user account of the user who is currently logged in? Basically I need my script to be able to delete any user based on the username that is supplied to the script (via POST/CURL), is this even possible? Like I said it seems to work but I still get the annoying error message!

Thanks
Reply With Quote
  #8  
Old 01-03-2007, 08:47 PM
Cloudrunner's Avatar
Cloudrunner Cloudrunner is offline
 
Join Date: May 2003
Location: Butte, MT
Posts: 635
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Remove please!
Reply With Quote
  #9  
Old 01-23-2007, 02:32 PM
bigtime bigtime is offline
 
Join Date: Jun 2002
Location: Houston, Texas
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ever find the solution for this?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09126 seconds
  • Memory Usage 2,236KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete