Reading SMFCookie262 for Login

Started by Minecraft Manager, October 16, 2015, 03:23:13 PM

Previous topic - Next topic

Minecraft Manager

Ok that defiantly works but how can I get the product key as well?

Kindred



global $context;

$request = $smcFunc['db_query']('', '
SELECT member_ip, product_key
FROM {db_prefix}members
WHERE ' . ('id_member') . ' = {string:id}
LIMIT 1',
array(
'id' => $context['user']['id'],
)
);


or $user_info['id'] instead of $context['user']['id']
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Minecraft Manager


function ssi_getProductKey()
{
if ($id === null)
return "user id invalid";

$request = $smcFunc['db_query']('', '
SELECT member_ip, product_key
FROM {db_prefix}members
WHERE ' . ('id_member') . ' = {string:id}
LIMIT 1',
array(
'id' => $user_info['id'],
)
);

$prd_key = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

return $product_key == $prd_key;
}
echo '[product_key] => '  . ssi_getProductKey();


this doesn't work as the "user id invalid" catch is returned.

Illori

change global $context;
to

global $context, $user_info;

Minecraft Manager

nope still the same result.

Right this is my full code:
<?php
require(dirname(__FILE__) . '/SSI.php');
ssi_login();
$product_key null;

global 
$db_prefix$sourcedir$smcFunc;

global 
$context$user_info;

function 
ssi_getProductKey()
{
if ($id === null)
return "user id invalid";

$request $smcFunc['db_query']('''
SELECT member_ip, product_key
FROM {db_prefix}members
WHERE ' 
. ('id_member') . ' = {string:id}
LIMIT 1'
,
array(
'id' => $user_info['id'],
)
);

$prd_key $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

return $product_key == $prd_key;
}

echo 
'<pre>';
print_r($user_info);
echo 
'[product_key] => ' ssi_getProductKey();
echo 
'</pre>';
?>

Illori

you are not defining $id, so it will always be undefined. remove that if statement and try again.

Minecraft Manager

the output is just: "Array"

tbh I don't want it in an Array because I just need the value.

Kindred

ummm....   well, you did select TWO objects....  so, of course it is an array


Why did you select the IP address as well if all you want is the product key?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Minecraft Manager

No I don't need member_ip now if it's in the $user_info but I do need the product_key.
Also ssi_login(); doesn't work with _POST from a C# application.

Kindred

that is because all of the SSI functions. like everything else with SMF is php script.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Minecraft Manager

Ok but I need to be able to login with my C# Application before I can get the users information. Can you help with maybe a _POST method to login and return this information back please.

Advertisement: