Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
Prev Previous Post   Next Post Next
  #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
 

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 09:00 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.07687 seconds
  • Memory Usage 2,507KB
  • Queries Executed 12 (?)
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
  • (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)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • 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_threaded
  • showthread_threaded_construct_link
  • 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