vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Deleting Users via the Data manager (https://vborg.vbsupport.ru/showthread.php?t=125783)

hsomel 09-04-2006 01:14 PM

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

Wild-Wing 09-04-2006 01:17 PM

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

hsomel 09-04-2006 01:41 PM

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

Wild-Wing 09-04-2006 02:18 PM

you might need to add this in require_once(DIR . '/includes/adminfunctions.php');

hsomel 09-04-2006 02:25 PM

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

Wild-Wing 09-04-2006 02:28 PM

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

hsomel 09-04-2006 02:41 PM

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

Cloudrunner 01-03-2007 08:47 PM

Remove please!

bigtime 01-23-2007 02:32 PM

Ever find the solution for this?


All times are GMT. The time now is 10:38 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00988 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete