Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2005, 04:47 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default code help

Ok I managed to get alot of this ported hack working, but when I go into my admincp->users->my admin account->Add Linked Accounts to (user)

I then enter the userid to link to, a list of all accounts show up, that doesn't bother me, I click on (Link) which then is supposed to link the 2 accounts together but instead it does nothing, its supposed to give a message stating the accounts were linked.

Any ideas what could be wrong?

I am providing the code that I had to use and the qas.php file. If you wish to look over it and provide better feedback, please do. It suggested I check that 'u' is being converted to 'userid' but I have no clue what I'm looking for when it comes to that.

global.php add in code:
HTML Code:
# Quick Account Switch v1.2
unset($account_master); // empty markup for good measure
if ($bbuserinfo['userid']) // verify we are logged on
{
	if ($bbuserinfo['qas']) // slave or master account defined?
	{
		$qas = unserialize($bbuserinfo['qas']);
		foreach ($qas as $qas_acct => $qas_acct_value)
		{
			if ('m'==$qas_acct_value['type']) // we are a master account to this slave account
			{
				$account_master .= "<tr><td class=\"vbmenu_option\"><a href=\"login.php?do=switch&id=$qas_acct_value[userid]\">" . base64_decode($qas_acct_value['username']) ."</a></td></tr>";
			}
			else // we are a slave account to this master account
			{
				$qasmast=fetch_userinfo($qas_acct_value['userid'], 0); // get master account's QAS details
				// add master account at the top of the list
				$account_master .= "<tr><td class=\"vbmenu_option\"><a href=\"login.php?do=switch&id=$qasmast[userid]\">$qasmast[username]</a></td></tr>";
				// add all slaves except myself
				$qas2 = unserialize($qasmast['qas']);
				foreach ($qas2 as $qas_acct2 => $qas_acct_value2)
				{
					if ($qas_acct_value2['userid'] != $bbuserinfo['userid']) // if I'm not this slave
					{
						$account_master .= "<tr><td class=\"vbmenu_option\"><a href=\"login.php?do=switch&id=$qas_acct_value2[userid]\">" . base64_decode($qas_acct_value2['username']) . "</a></td></tr>";
					}
				}
			}
		}
	}
}
# /Quick Account Switch v1.2
login.php add in code:
HTML Code:
// ##### start do switch # Quick Account Switch v1.2 #####
if ($_REQUEST['do'] == 'switch')
{
	globalize($_REQUEST, array('url' => STR, 'userid' => INT));
	$allow_switch = false;

	if (($bbuserinfo['userid']) && $_REQUEST['id']) {
		$id_from = $bbuserinfo['userid'];
		$id_to = $_REQUEST['id'];
		if ($bbuserinfo['qas']) // slave or master account defined?
		{
			$qas = unserialize($bbuserinfo['qas']);
			foreach ($qas as $qas_acct => $qas_acct_value)
			{
				if ('m'==$qas_acct_value['type']) // we are a master account to this slave account
				{
					if ($id_to == $qas_acct_value['userid']) $allow_switch = true;
				}
				else // we are a slave account to this master account
				{
					if ($id_to == $qas_acct_value['userid'])
					{ // are we switching to the master account?
						$allow_switch = true;
					}
					else
					{ // check the slaves
						$qasmast=fetch_userinfo($qas_acct_value['userid'], 0); // get master account's QAS details
						// allow switching to all but myself, since that's futile
						$qas2 = unserialize($qasmast['qas']);
						foreach ($qas2 as $qas_acct2 => $qas_acct_value2)
						{
							if ($qas_acct_value2['userid'] != $bbuserinfo['userid']) // if I'm not this slave
							{
								if ($id_to == $qas_acct_value2['userid']) $allow_switch = true;
							}
						}
					}
				}
			}
		}
	}
	
	if ($logintype === 'cplogin' OR $logintype === 'modcplogin') $allow_switch = false;

	if ($allow_switch == false)
	{
		eval(print_standard_error('logout_missing_userid'));
	} else {

		// clear all cookies beginning with COOKIE_PREFIX
		$prefix_length = strlen(COOKIE_PREFIX);
		foreach ($_COOKIE AS $key => $val)
		{
			$index = strpos($key, COOKIE_PREFIX);
			if ($index == 0 AND $index !== false)
			{
				$key = substr($key, $prefix_length);
				if (trim($key) == '')
				{
					continue;
				}
				if ($key != 'sessionhash') vbsetcookie($key, '', 1);
			}
		}

		if ($bbuserinfo['userid'] != 0 AND $bbuserinfo['userid'] != -1)
		{
			$DB_site->query("
				UPDATE " . TABLE_PREFIX . "user
				SET lastactivity = " . (TIMENOW - $vboptions['cookietimeout']) . ",
					lastvisit = " . TIMENOW . "
				WHERE userid = $bbuserinfo[userid]
			");

			// make sure any other of this user's sessions are deleted (in case they ended up with more than one)
			$DB_site->query("DELETE FROM " . TABLE_PREFIX . "session WHERE userid = $bbuserinfo[userid]");
		}
		// clear current sessionhash
		$DB_site->query("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . addslashes($session['dbsessionhash']) . "'");

		// so much for logging out, lets login the assumed user
		$bbuserinfo = $DB_site->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE userid = '" . $id_to . "'");

		vbsetcookie('userid', $bbuserinfo['userid']);
		// *** put your license code here or it'll not work *** you can find it at the top of this file (login.php)
		// the format is Lxxxxxxx, where 'xxxxxxx' is a set of numbers/letters, 0-9, a-f.
		// replace <*** your license code ***> in the next line with this code, between the single quotes.
		vbsetcookie('password', md5($bbuserinfo['password'] . '<*** your license code ***>'));

		exec_unstrike_user($bbuserinfo['username']);

		$DB_site->query("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . addslashes($session['dbsessionhash']) . "'");

		$session['sessionhash'] = fetch_sessionhash();
		$session['dbsessionhash'] = $session['sessionhash'];
		$DB_site->query("
			INSERT INTO " . TABLE_PREFIX . "session
				(sessionhash, userid, host, idhash, lastactivity, styleid, loggedin, bypass, useragent)
			VALUES
				('" . addslashes($session['sessionhash']) . "', " . intval($bbuserinfo['userid']) . ", '" . addslashes(SESSION_HOST) . "', '" . addslashes(SESSION_IDHASH) . "', " . TIMENOW . ", $session[styleid], 1, " . iif ($logintype === 'cplogin', 1, 0) . ", '" . addslashes(USER_AGENT) . "')
		");
		vbsetcookie('sessionhash', $session['sessionhash'], 0);

		if ($nosessionhash == 1)
		{ // if user is working through cookies, blank out the sessionhash
			$shash = $session['sessionhash'] = '';
			$surl = $session['sessionurl'] = '';
			$surlJS = $session['sessionurl_js'] = '';
		}
		else
		{
			$shash = $session['sessionhash'];
			$surl = $session['sessionurl'] = 's=' . $session['sessionhash'] . '&amp;';
			$surlJS = $session['sessionurl_js'] = 's=' . $session['sessionhash'] . '&';
		}

		if ($url == 'login.php' OR $url == "$vboptions[forumhome].php" OR strpos($url, 'do=logout') !== false)
		{
			$url = "$vboptions[forumhome].php?$surl";
		}
		else
		{
			$url = fetch_replaced_session_url($url);
		}

		$postvars = construct_hidden_var_fields($postvars);

		$temp = strpos($url, '?');
		if ($temp)
		{
			$formfile = substr($url, 0, $temp);
		}
		else
		{
			$formfile = $url;
		}

		eval(print_standard_redirect('redirect_login'));
	}
}
admincp/user.php add in code:
HTML Code:
// Quick Account Switch 1.2 - Start
	$qas_is_slave=false;
	print_table_header($vbphrase['qas_version']);
	if (!empty($user['qas']))
	{
		$qas = unserialize($user['qas']);
		foreach ($qas as $qas_acct => $qas_acct_value)
		{
			if ('m'==$qas_acct_value['type']) // we are a master account to this slave account
			{
				$qas_link = "(<a href=\"user.php?$session[sessionurl]&do=edit&u=$qas_acct_value[userid]\">$vbphrase[profile]</a>)";
				// parameters: u2 (slave),  u (master)
				$qas_link .= " (<a href=\"qas.php?$session[sessionurl]&do=qasunlink&u=$user[userid]&u2=$qas_acct_value[userid]\">$vbphrase[qas_unlink]</a>)";
				print_label_row($vbphrase['qas_master_to'] . ' ' . base64_decode($qas_acct_value['username']), $qas_link);
			}
			else // we are a slave account to this master account
			{
				$qas_link = "(<a href=\"user.php?$session[sessionurl]&do=edit&u=$qas_acct_value[userid]\">$vbphrase[profile]</a>)";
				$qas_link .= " (<a href=\"qas.php?$session[sessionurl]&do=qasunlink&u=$qas_acct_value[userid]&u2=$user[userid]\">$vbphrase[qas_unlink]</a>)";
				print_label_row($vbphrase['qas_slave_to'] . ' ' . base64_decode($qas_acct_value['username']), $qas_link);
				$qas_is_slave = true;
			}
		}
	}
	else
	{
		print_label_row($vbphrase['qas_no_accounts'], '', '', 'top', 'noslaves');
	}
	if (!$qas_is_slave)
	{
		$qas_link = " <a href=\"qas.php?$session[sessionurl]&do=qaslink&u=$user[userid]\">$vbphrase[qas_add_to] $user[username]</a>";
		print_description_row($qas_link);
	}
	print_table_break('', $INNERTABLEWIDTH);
	
	// Quick Account Switch 1.2 - End
Any help much appreciated and Marco, if you can help that would be great.

Cheers and thanks
Myth
Reply With Quote
  #2  
Old 09-11-2005, 04:58 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you asked Ianomed for Permission?
Reply With Quote
  #3  
Old 09-11-2005, 05:00 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First what i notice is that you still have references to vB3.0 variables, such as $bbuserinfo (this should be $vbulletin->userinfo), and $DB_site ($vbulletin->db).
Reply With Quote
  #4  
Old 09-11-2005, 05:00 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tried but no go, he is MIA, his partner said ok to it as long as credit was pointed back to Ianomed so that is what I'm doing.

Marco, I was told to change $DB_site to $db only. Am I wrong in doing that?

Ok changed what you suggested Marco and still same problem. I am just wondering why its not inserting the information into the database once I click on (Link) right next to the username. I providing a screenshot of where the link is.

Hope you can see the image clear enough.
Reply With Quote
  #5  
Old 09-11-2005, 05:20 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$db is fine in global context.
Did you actually do anything with this Code?
Looks like 100% 3.0 ...
Reply With Quote
  #6  
Old 09-11-2005, 05:22 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is one of my small problems, I have been changing the code over to 3.5 as much as possible, that is why I posted up the code and the file as I need to know what has to be changed in it to match 3.5 as I pretty much have come to a dead in. No more errors when entering the linking section but now it just doesn't want to enter the information into the database.

But if I have $vbulletin->db I'm still ok, right?
Reply With Quote
  #7  
Old 09-11-2005, 05:27 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wonder how you ported anything without knowing the basics ...

$vboptions = $vbulletin->options
$DB_site = $db (Or $vbulletin->db, it's the same anyway)
$bbuserinfo = $vbulletin->userinfo
$session = $vbulletin->session->vars
addslashes() = $db->escape_string()
globalize = $vbulletin->input->clean_array_gpc, the Types have also changed
print_standard_error() = standard_error(fetch_error())

Change all that, check if there are errors - and then ask again
Reply With Quote
  #8  
Old 09-11-2005, 05:29 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LOL

Kirby, I managed to port by just trying certain things, getting errors, and changing to other things. But now its becoming a bit trickier.

Ok going to check those now.

Quick on globalize, should that be $vbulletin->input->clean_array_gpc or $vbulletin->input->clean_gpc ?

Ok done, found quite a few spots I missed for $DB_site

No errors just that its still not inserting info into the database.

Well I'm off to bed to sleep a bit, I will look forward to seeing you reply.

Thanks Kirby and Marco.

Cheers
Myth (Steve)

EDIT: Ok no go as of yet, not sure what else needs to be checked. Anyone that can list what has changed since 3.0.x then I can easily go through and double check my work.
Reply With Quote
Reply


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 02:59 PM.


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.04556 seconds
  • Memory Usage 2,247KB
  • 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
  • (3)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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