Customizing SMF > Portals, Bridges, and Integrations

New tools to help integrating SMF with something else

<< < (12/27) > >>

Andre N:
@lilsammy1989 You don't appear to have a Settings.php file in your forum root directory... The API needs that location of the Settings.php file so it can make the db connections and get the cookiename to read the cookie... How does your forum work without it?

@frytec That's very weird. Your cookie is being read correctly but the logout is still failing for you. Try calling smfapi_loadUserSettings() before logout, and also, don't pass any variable to the logout function:

--- Code: ---smfapi_loadUserSettings();
smfapi_logout();

--- End code ---
If that doesn't work, try modifying it like so:

--- Code: ---smfapi_loadUserSettings();
global $user_info;
echo '<pre>';
print_r($user_info);
echo '</pre>';
exit('The user info should be above in an array');
smfapi_logout();

--- End code ---
and see if the API is getting the current user from the cookie.

lilsammy1989:
Its there sorry I knew that I should of mentioned I did not download my entire forum as installed it from another location and did not need the files on this PC so didn't bother downloading the entire remote forums folder but its there on the actual server thats my local view.

Sorry for the confusion.

frytec:

--- Quote from: andre nickatina ---@frytec That's very weird. Your cookie is being read correctly but the logout is still failing for you. Try calling smfapi_loadUserSettings() before logout, and also, don't pass any variable to the logout function:

--- Code: ---smfapi_loadUserSettings();
smfapi_logout();

--- End code ---

--- End quote ---

that does not work.


--- Quote from: andre nickatina ---If that doesn't work, try modifying it like so:

--- Code: ---smfapi_loadUserSettings();
global $user_info;
echo '<pre>';
print_r($user_info);
echo '</pre>';
exit('The user info should be above in an array');
smfapi_logout();

--- End code ---
and see if the API is getting the current user from the cookie.

--- End quote ---

this give me a page with above results, but still dont logout from smf.


--- Code: ---Array
(
    [groups] => Array
        (
            [0] => 1
            [1] => 0
        )

    [possibly_robot] =>
    [id] => 1
    [username] => catalink
    [name] => catalink
    [email] => suporte@catalink.com.br
    [passwd] => 8769590b35433ffbfc768e09af9efda6fc8bfb4a
    [language] => portuguese_brazilian-utf8
    [is_guest] =>
    [is_admin] => 1
    [theme] => 0
    [last_login] => 1330199182
    [ip] =>
    [ip2] =>
    [posts] => 0
    [time_format] => %B %d, %Y, %I:%M:%S %p
    [time_offset] => 0
    [avatar] => Array
        (
            [url] =>
            [filename] =>
            [custom_dir] =>
            [id_attach] => 0
        )

    [smiley_set] =>
    [messages] => 0
    [unread_messages] => 0
    [total_time_logged_in] => 8878
    [buddies] => Array
        (
        )

    [ignoreboards] => Array
        (
        )

    [ignoreusers] => Array
        (
        )

    [warning] => 0
    [permissions] => Array
        (
        )

)

The user info should be above in an array
--- End code ---

Andre N:
@frytec I think I see your problem. There is a bug in the logout function. Go to ~line 1047 of the API to where the code says:

--- Code: ---    if (!$user_data) {
        if (isset($user_info['id_member']) && false !== smfapi_getUserById($user_info['id_member'])) {
            $user_data['id_member'] = $user_info['id_member'];
        } else {
            return false;
        }
    }

--- End code ---
and change it to

--- Code: ---    if (!$user_data) {
        if (isset($user_info['id']) && false !== smfapi_getUserById($user_info['id'])) {
            $user_data['id_member'] = $user_info['id'];
        } else {
            return false;
        }
    }

--- End code ---
It looks like I had been using the wrong variable name for the member ID  :-[

@lilsammy1989 Please confirm you have the API script in the same directory as the Settings.php file. Also, look for a file named smfapi_settings.txt and delete it so the API can generate a new one with the correct path. If you want to specify the path in the, do it like this:

--- Code: ---$_SERVER['DOCUMENT_ROOT'] . '/forums/Settings.php';

--- End code ---
That looks like it is the path you should use. That won't be necessary if you have the API in the same directory as the settings file though... either way, try it and let me know :)

lilsammy1989:
@andre nickatina

Thanks it worked when I used it from the forum and set the directory to settings. Can I ask tho why when I made my registration function quoted below it worked fine and its located outside of the forum directory?


--- Code: ---<?php
if (!isset($_POST['name']) && !isset($_POST['steam']) && !isset($_POST['email']) && !isset($_POST['email2']) && !isset($_POST['password']) && !isset($_POST['password2']) && !isset($_POST['acceptTerms'])) {
echo "";
}else{
include './static/classes/validation.php';

$name = $_POST['name'];
$steam = $_POST['steam'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
$pass = $_POST['password'];
$pass2 = $_POST['password2'];
$userIP = getenv('REMOTE_ADDR');
require_once ('./static/classes/smf_2_api.php');

$sha_passwd = sha1(strtolower($name).smfapi_unHtmlspecialchars($pass));
  
if((validate_username($name) == true) && ($email == $email2) && (check_email_address($email) == true) && ($pass == $pass2)){
include './static/classes/config.php';

$conn = mysql_connect($host,$user,$pass);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db($db, $conn);
mysql_set_charset('utf8',$conn);

$sql_username="SELECT * FROM User WHERE User_Name = '$name'";
$sql_email="SELECT * FROM User WHERE User_Email = '$email'";

$user_check=mysql_query($sql_username);
$email_check=mysql_query($sql_email);

if (mysql_num_rows($user_check) > 0){
echo "Error - 02"; // Username in Use.
}else{
if (mysql_num_rows($email_check) > 0){
echo "Error - 03"; // Email in Use.
}else{

$reg= array(
'member_name' => $name,
'email' => $email,
'require' => 'nothing',
'password' => $pass,
'password_check' => $pass2,
);
smfapi_registerMember($reg);

$new_user=mysql_query("INSERT INTO User (User_Name, User_Pass, User_IP, User_Admin, User_Beta, User_SteamID, User_Registered, User_Email) VALUES ('$name', '$sha_passwd', '$userIP', '0', '1', '$steam', 'NOW()', '$email')");
if (!$new_user) {
$message  = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
};

echo "<script language='javascript'>window.location.href='http://mysite.com/welcome.php?name=".$name."';</script>";
};
};
};
};
?>
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version