Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: [Unknown] on September 12, 2004, 07:39:35 PM

Title: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on September 12, 2004, 07:39:35 PM
The purpose of this tool is to facilitate easy integration of SMF into other scripts and software.  Previously, this was done with SSI.php, but that pulls in most of SMF and can become very bloated for general usage inside another large software.  It also meant the possibility of naming conflicts, the two softwares fighting over output buffering, and many other problems.  Even past that, there have been licensing problems.

This tool is not yet complete, but it has been developed to ease all of these problems.  It is a single file, separate from SMF's code.  It may also be available under alternative licenses - please reply here or contact me, Jeff Lewis, or another team member for additional details.

It is available here:

http://www.simplemachines.org/download.php?converters

If you have any concerns or problems with it, or believe anything should be added to it (remembering that it is meant to be lightweight!) please don't hesitate to comment.

Thanks,
-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on September 13, 2004, 01:02:11 AM
I've just updated it once more with something rather critical: session support ;).

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Tony Reid on September 13, 2004, 06:38:41 AM
Hey cant wait to play with this tonight :)

Thanks!!
Tony,
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Vinoth on September 13, 2004, 07:55:31 AM
well features over the SSI other than u sited,fighting over output buffering
what can we do with this???
Title: Re: A new tool is available for download. (smf_api.php)
Post by: roboter88 on September 13, 2004, 09:39:34 AM
We can integrating eg. SMF or any other php application :)

http://coppermine.sourceforge.net/board/index.php?topic=9934.0


cheers
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Xavier on September 13, 2004, 03:17:33 PM
Ok...
I have integrate this code at the first part of smf.inc.php of coppermine gallery

require_once('../forum/smf_api.php');

smf_authenticateUser();
smf_loadSession();
smf_logOnline('coppermine');

The logout run correctly, but i have some error on the page

Notice: Constant ¨Òë 6 already defined in /home/httpd/vhosts/gothic-culture.net/httpdocs/gallery/bridge/smf.inc.php on line 85

Notice: A session had already been started - ignoring session_start() in /home/httpd/vhosts/gothic-culture.net/httpdocs/gallery/bridge/smf.inc.php on line 154

Fatal error: Call to undefined function: db_affected_rows() in /home/httpd/vhosts/gothic-culture.net/httpdocs/forum/smf_api.php on line 591

Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

and the gallery not run correctly... Only the logout now run -_-
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on September 14, 2004, 02:13:17 AM
I replied on the coppermine forum - however, I might note that there was a typo in the download (serves me right for updating it at something like 2 am) and so I updated it once more.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on November 04, 2004, 05:06:36 AM
I've installed SMF just yesterday and am trying to connect to it using smf_api.php. So far so good :)

I've also fixed that I can login, so that works as well.

Now I'm trying to log out of SMF through smf_api.php. Imho this would work by destroying the session using smf_sessionDestroy( string session_id ). So I get the session_id from $smf_user_info and pass it through to the function, but somehow it doesn't seem to work. The error I get is:

Fatal error: Call to undefined function: db_query() in /home/aize/www/syn-3/forum/smf_api.php on line 609

The name of the function sounded familliar to me, because I have a similar function with the same name in my own system. So I've renamed that function.

So I've looked up this function and it seems that the session is deleted from the database here. 'Not to worry', I think and stopped using the DB for my sessions. But that doesn't help either ...

What am I doing wrong?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: ms_ukyankee on November 04, 2004, 05:32:10 AM
I used this to logout.

smf_setLoginCookie(-3600, $userid, $userpassword);

Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on November 04, 2004, 05:48:54 AM
No, session destroy is not what you want.  What Leah posted should work.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on November 04, 2004, 05:57:29 AM
That does the trick, thanks guys :-*
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on November 04, 2004, 08:54:03 AM
Next problem ... can I use smf_query for inserts?
When I try to it returns nothing, but there is no error in the log, although there should be ... returning the mysql_error() lets me know there is a problem freeing the resultset. Wich is the logical thing with an insert, because there is no resultset.

So no error in the log and no new data in the database :(

How do I insert sth into the DB or is inserting prohibited? It doesn't say so in the comments.
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on November 04, 2004, 04:01:43 PM
From smf_api.php:
smf_query("
INSERT IGNORE INTO $smf_settings[db_prefix]log_online
(session, ID_MEMBER, ip, url)
VALUES ('ip$_SERVER[REMOTE_ADDR]', 0, IFNULL(INET_ATON('$_SERVER[REMOTE_ADDR]'), 0), '$serialized')", __FILE__, __LINE__);


So, yes, you can insert.

If nothing happens, it probably means no connection could be made to the database.  Try outputting the mysql_error() at various stages.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on November 05, 2004, 03:21:16 AM
I've been testing some things and I think the problems was in the fact that I have two DB-connections open and I didn't specify the databasename in the query.
As soon as I did sepcify the db-name, it worked :)
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 10, 2005, 04:45:59 AM
Is the smf_api compatible with SMF 1.0? I've upgraded and it doesn't seem to work :(
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 10, 2005, 04:54:03 AM
It should be.  Try downloading the latest one from the download page.

We use it for some tools on this site (and they still work.)

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 10, 2005, 05:01:06 AM
Ah ... somehow registering users does work, butt logging on and off doesn't.
I'll try upgrading first.

[update]
Upgraded, now I don't get any response form AuthenticateUser(). Not true and no false ...

In the session only [login_SMFCookie10] is set, that used to be different, wasn't it?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 11, 2005, 08:14:08 AM
Somehow smf_authenticateUser doesn't give feedback anymore. So instead of using it in an if-statement I placed it outside of the  statement. Still not logged on.
Turned off database-driven sessions and that did the trick!

So tried putting smf_authenticateUser back in the if-statement, but that gave me an error again, so I just decided to skip the if-statement.

[update]
After some more testing I found out that the authenticateUser-function still doesn't work :( Going to the forum, you're not logged on. As soon as you refresh the page though ... you are ???

/me is getting a little frustrated ::)
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Kindred on January 11, 2005, 09:20:51 AM
AH!   Yes, this could also be the cause of an issue with the "who's online" module for the Mambo-SMF bridge...

Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 11, 2005, 07:33:58 PM
Quote from: Shedman on January 11, 2005, 08:14:08 AM
After some more testing I found out that the authenticateUser-function still doesn't work :( Going to the forum, you're not logged on. As soon as you refresh the page though ... you are ???

/me is getting a little frustrated ::)

Make sure:
  - you're using smf_loadSession().
  - you've got "subdomain independent cookies" enabled and "local cookies" disabled.
  - the cookie is being sent properly.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 12, 2005, 03:53:09 AM
Quote from: [Unknown] on January 11, 2005, 07:33:58 PM
[...]

Make sure:
- you're using smf_loadSession().
- you've got "subdomain independent cookies" enabled and "local cookies" disabled.
- the cookie is being sent properly.

-[Unknown]

To login to SMF I use:
Step 1: smf_setLoginCookie( 10000000000, $_SESSION[ 'userid' ], $password, false ) )
Step 2: smf_authenticateUser();
Step 3: smf_loadSession();

Subdomain independent cookies are on, local cookies are off.

The cookie seems to be set properly, but still it doesn't work most of the time ...
Somehow it looks like the session isn't loaded properly, but that could be because the user isn't authenticated properly?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 12, 2005, 04:31:19 AM
Hmm... try loadSession before authenticateUser?

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 12, 2005, 10:38:59 AM
Nope, no luck with that either :(
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 14, 2005, 02:59:40 AM
Just upgraded to 1.0.1. Problem solved :)
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 04:14:33 AM
Hmmm ... it seems my conclusion was too soon. Had some complaints about loggin on in my e-mail this morning.

So upgraded to the last version of the api and started testing again. Somehow smf_AuthenticateUser is not processed correctly. It should return true or false, but I don't get any feedback (which probably signals it to be false ...)
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 05:55:10 AM
Try this with error_reporting at E_ALL:

function smf_authenticateUser()
{
global $smf_connection, $smf_settings, $smf_user_info;

// No connection, no authentication!
if (!$smf_connection)
{
trigger_error('No database connection', E_USER_WARNING);
return false;
}

// Check first the cookie, then the session.
if (isset($_COOKIE[$smf_settings['cookiename']]))
{
$_COOKIE[$smf_settings['cookiename']] = stripslashes($_COOKIE[$smf_settings['cookiename']]);

// Fix a security hole in PHP 4.3.9 and below...
if (preg_match('~^a:3:\{i:0;(i:\d{1,6}|s:[1-6]:"\d{1,6}");i:1;s:(0|32):"([a-fA-F0-9]{32})?";i:2;i:\d{1,12};\}$~', $_COOKIE[$smf_settings['cookiename']]) == 1)
{
list ($ID_MEMBER, $password) = @unserialize($_COOKIE[$smf_settings['cookiename']]);
$ID_MEMBER = !empty($ID_MEMBER) ? (int) $ID_MEMBER : 0;
}
else
{
$ID_MEMBER = 0;
trigger_error('Invalid cookie', E_USER_WARNING);
}
}
elseif (isset($_SESSION['login_' . $smf_settings['cookiename']]))
{
list ($ID_MEMBER, $password, $login_span) = @unserialize(stripslashes($_SESSION['login_' . $smf_settings['cookiename']]));
$ID_MEMBER = !empty($ID_MEMBER) && $login_span > time() ? (int) $ID_MEMBER : 0;
}
else
{
trigger_error('No cookie found', E_USER_NOTICE);
$ID_MEMBER = 0;
}

// Don't even bother if they have no authentication data.
if (!empty($ID_MEMBER))
{
$request = smf_query("
SELECT *
FROM $smf_settings[db_prefix]members
WHERE ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
// Did we find 'im?  If not, junk it.
if (mysql_num_rows($request) != 0)
{
// The base settings array.
$smf_user_info = mysql_fetch_assoc($request);

// Wrong password or not activated - either way, you're going nowhere.
$ID_MEMBER = smf_md5_hmac($smf_user_info['passwd'], 'ys') != $password || $smf_user_info['is_activated'] != 1 ? 0 : $smf_user_info['ID_MEMBER'];

if (empty($ID_MEMBER))
trigger_error('Password incorrect', E_USER_WARNING);
}
else
{
$ID_MEMBER = 0;
trigger_error('Member not found', E_USER_WARNING);
}
mysql_free_result($request);
}

if (empty($ID_MEMBER))
$smf_user_info = array('groups' => array(-1));
else
{
if (empty($smf_user_info['additionalGroups']))
$smf_user_info['groups'] = array($smf_user_info['ID_GROUP'], $smf_user_info['ID_POST_GROUP']);
else
$smf_user_info['groups'] = array_merge(
array($smf_user_info['ID_GROUP'], $smf_user_info['ID_POST_GROUP']),
explode(',', $smf_user_info['additionalGroups'])
);
}

// A few things to make life easier...
$smf_user_info['id'] = &$smf_user_info['ID_MEMBER'];
$smf_user_info['username'] = &$smf_user_info['memberName'];
$smf_user_info['name'] = &$smf_user_info['realName'];
$smf_user_info['email'] = &$smf_user_info['emailAddress'];
$smf_user_info['messages'] = &$smf_user_info['instantMessages'];
$smf_user_info['unread_messages'] = &$smf_user_info['unreadMessages'];
$smf_user_info['language'] = empty($smf_user_info['lngfile']) || empty($smf_settings['userLanguage']) ? $smf_settings['language'] : $smf_user_info['lngfile'];
$smf_user_info['is_guest'] = $ID_MEMBER == 0;
$smf_user_info['is_admin'] = in_array(1, $smf_user_info['groups']);

// This might be set to "forum default"...
if (empty($smf_user_info['timeFormat']))
$smf_user_info['timeFormat'] = $smf_settings['time_format'];

return !$smf_user_info['is_guest'];
}


It should generate notices and warnings.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 06:12:43 AM
Tried that: no errors ???
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 06:26:13 AM
Okay, let's try this.  Are you certain you've got E_ALL, with notices though?  Just in case that's it... this one's gonna be much more verbose, though.

function smf_authenticateUser()
{
global $smf_connection, $smf_settings, $smf_user_info;

// No connection, no authentication!
if (!$smf_connection)
{
trigger_error('No database connection', E_USER_WARNING);
return false;
}

// Check first the cookie, then the session.
if (isset($_COOKIE[$smf_settings['cookiename']]))
{
$_COOKIE[$smf_settings['cookiename']] = stripslashes($_COOKIE[$smf_settings['cookiename']]);

// Fix a security hole in PHP 4.3.9 and below...
if (preg_match('~^a:3:\{i:0;(i:\d{1,6}|s:[1-6]:"\d{1,6}");i:1;s:(0|32):"([a-fA-F0-9]{32})?";i:2;i:\d{1,12};\}$~', $_COOKIE[$smf_settings['cookiename']]) == 1)
{
list ($ID_MEMBER, $password) = @unserialize($_COOKIE[$smf_settings['cookiename']]);
$ID_MEMBER = !empty($ID_MEMBER) ? (int) $ID_MEMBER : 0;
trigger_error('Cookie indicates ID_MEMBER of ' . $ID_MEMBER, E_USER_NOTICE);
}
else
{
$ID_MEMBER = 0;
trigger_error('Invalid cookie', E_USER_WARNING);
}
}
elseif (isset($_SESSION['login_' . $smf_settings['cookiename']]))
{
list ($ID_MEMBER, $password, $login_span) = @unserialize(stripslashes($_SESSION['login_' . $smf_settings['cookiename']]));
$ID_MEMBER = !empty($ID_MEMBER) && $login_span > time() ? (int) $ID_MEMBER : 0;
trigger_error('Session indicates ID_MEMBER of ' . $ID_MEMBER, E_USER_NOTICE);
}
else
{
trigger_error('No cookie found', E_USER_NOTICE);
$ID_MEMBER = 0;
}

// Don't even bother if they have no authentication data.
if (!empty($ID_MEMBER))
{
$request = smf_query("
SELECT *
FROM $smf_settings[db_prefix]members
WHERE ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
// Did we find 'im?  If not, junk it.
if (mysql_num_rows($request) != 0)
{
// The base settings array.
$smf_user_info = mysql_fetch_assoc($request);

// Wrong password or not activated - either way, you're going nowhere.
$ID_MEMBER = smf_md5_hmac($smf_user_info['passwd'], 'ys') != $password || $smf_user_info['is_activated'] != 1 ? 0 : $smf_user_info['ID_MEMBER'];

if (empty($ID_MEMBER))
trigger_error('Password incorrect', E_USER_WARNING);
else
trigger_error('Correct password', E_USER_NOTICE);
}
else
{
$ID_MEMBER = 0;
trigger_error('Member not found', E_USER_WARNING);
}
mysql_free_result($request);
}

if (empty($ID_MEMBER))
$smf_user_info = array('groups' => array(-1));
else
{
if (empty($smf_user_info['additionalGroups']))
$smf_user_info['groups'] = array($smf_user_info['ID_GROUP'], $smf_user_info['ID_POST_GROUP']);
else
$smf_user_info['groups'] = array_merge(
array($smf_user_info['ID_GROUP'], $smf_user_info['ID_POST_GROUP']),
explode(',', $smf_user_info['additionalGroups'])
);
}

// A few things to make life easier...
$smf_user_info['id'] = &$smf_user_info['ID_MEMBER'];
$smf_user_info['username'] = &$smf_user_info['memberName'];
$smf_user_info['name'] = &$smf_user_info['realName'];
$smf_user_info['email'] = &$smf_user_info['emailAddress'];
$smf_user_info['messages'] = &$smf_user_info['instantMessages'];
$smf_user_info['unread_messages'] = &$smf_user_info['unreadMessages'];
$smf_user_info['language'] = empty($smf_user_info['lngfile']) || empty($smf_settings['userLanguage']) ? $smf_settings['language'] : $smf_user_info['lngfile'];
$smf_user_info['is_guest'] = $ID_MEMBER == 0;
$smf_user_info['is_admin'] = in_array(1, $smf_user_info['groups']);

// This might be set to "forum default"...
if (empty($smf_user_info['timeFormat']))
$smf_user_info['timeFormat'] = $smf_settings['time_format'];

return !$smf_user_info['is_guest'];
}


This should definitely generate something no matter what.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 07:33:23 AM
Hmmm ... something weird going on with Apache/PHP, but with error reporting turned on at runtime I get:

Warning: Cannot modify header information - headers already sent by (output started at /home/webuser/htdocs/syn-3.datux.nl/inloggen.php:17) in /home/webuser/htdocs/syn-3.datux.nl/forum/smf_api.php on line 258

Warning: Invalid cookie in /home/webuser/htdocs/syn-3.datux.nl/forum/smf_api.php on line 378

So sth is wrong with the cookie ...
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 07:38:04 AM
Make sure you turn on output buffering before calling smf_api.php functions after output... e.g.:

ob_start();

Hmm... maybe...

print_r($_COOKIE[$GLOBALS['smf_settings']['cookiename']]);

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 07:45:57 AM
Placed ob_start(); at the top of smf_api.php, which solves the first problem.

Output of the print_r is:
a:3:{i:0;i:1;i:1;s:32:"d6effa00e8531fc6344725bc87184c1b";i:2;d:11105965895;}
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 07:57:51 AM
echo preg_match('~^a:3:\{i:0;(i:\d{1,6}|s:[1-6]:"\d{1,6}");i:1;s:(0|32):"([a-fA-F0-9]{32})?";i:2;i:\d{1,12};\}$~', $_COOKIE[$GLOBALS['smf_settings']['cookiename']]);

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 08:00:01 AM
Output: 0
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 08:18:09 AM
Quote from: [Unknown] on January 17, 2005, 07:57:51 AM
echo preg_match('~^a:3:\{i:0;(i:\d{1,6}|s:[1-6]:"\d{1,6}");i:1;s:(0|32):"([a-fA-F0-9]{32})?";i:2;i:\d{1,12};\}$~', $_COOKIE[$GLOBALS['smf_settings']['cookiename']]);

-[Unknown]

I don't get that.  Wait, I see it.  d.

smf_setLoginCookie( 10000000000, $_SESSION[ 'userid' ], $password, false ) )

That number is too high.  I'll fix it in 1.1 so it's okay, though.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 08:30:01 AM
So how do I set it to 'forever'? 0?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 09:14:32 AM
3153600.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 09:16:03 AM
Is that simply the maximum value or really forever?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 17, 2005, 09:20:06 AM
It's about 6 years.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Shedman on January 17, 2005, 09:22:04 AM
That should be long enouogh :D

Thanks for the help...
Title: Re: A new tool is available for download. (smf_api.php)
Post by: JRSofty on January 18, 2005, 11:02:34 AM
I am starting to test it out right now and see if I like it better than the SSI.php file. Eventually I want to intergrate SMF with my own CMS that I am building and so I think this might be the tool I'm looking for. However I'm wondering if what you mean by it may be available under alternate licensing?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 18, 2005, 01:33:08 PM
Just that we're willing to license this file under different licenses (GPL, LGPL, BSD, etc.) such that it can be distributed with other programs.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: JRSofty on January 18, 2005, 02:11:25 PM
Ahh that would be nice. I had thought that it would be a charter membership type thing. Well that is good news and I'll continue my working with it and see what I can create ;)
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Aravot on January 25, 2005, 07:27:19 PM
Just wanted to make sure before I go ahead and start messing things, is this tool for smf/cpg logout issue. that is when I try to logout from cpg I get 'Session verification failed' error.

SMF 1.0.1
CPG 1.3.2

Login: 'test'
Pass: 'pastest'

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwebpages.charter.net%2Fosipof%2Fcpg%2Flogout.jpg&hash=e0823cb0118cdbaa615d71541c78fdaa2a4d9080)

Thank you
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 25, 2005, 08:10:07 PM
That issue was one of the purposes of this tool.  However, this is not drop-in and the current bridge will not automatically use it.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Aravot on January 25, 2005, 08:27:24 PM
Thanks for the reply, now what do I need to do to fix this issue.

QuoteSession verification failed. Please try logging out and back in again, and then try again.
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on January 25, 2005, 09:43:42 PM
Well, again, that's a bug in the bridge.  Regardless, in most cases it helps to turn off database-driven sessions.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: pohwc on June 23, 2005, 11:47:20 AM
hi,

i have this when i tried the smf_api.php
QuoteNotice: A session had already been started - ignoring session_start() in C:\apachefriends\xampp\htdocs\gallery\bridge\smf.inc.php on line 150
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on June 23, 2005, 02:49:07 PM
Please turn off session.auto_start in your php.ini.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: elfinit on July 14, 2005, 09:40:26 AM
Error logging does not work, because there isn't 'smf_modSettings'.
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on July 14, 2005, 05:17:31 PM
Quote from: elfinit on July 14, 2005, 09:40:26 AM
Error logging does not work, because there isn't 'smf_modSettings'.

That's been fixed in the 1.1 version, which is pending.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Anihc on July 15, 2005, 01:07:18 PM
I need to check tis out later too sounds interesting.
Title: Re: A new tool is available for download. (smf_api.php)
Post by: Trekkie101 on July 22, 2005, 11:19:34 AM
Quotestring smf_md5_hmac(string data, string key)
      - implements the encryption used for the passwords in SMF.
I was going to use that function in a sort of bridge with efiction because it uses just standard MD5, but SMF1.1 uses SHA-1, so is the SHA-1 function available as the 1.1 API as you said is pending. Or is there another way to do it, or should I just wait?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: S25 on August 18, 2005, 05:42:56 PM
Please pardon my ignorance but i wish to use this with my copy of MAMBO i am currently running the bridge and am unsure how to run this?PLease i would be very appreciative if you could provide me with instructions on using it.
Thanks in advance  ;D
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on August 18, 2005, 06:22:08 PM
You should probably use SSI.php in Mambo, since it is already used there for the bridge.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: np on September 04, 2005, 12:31:08 PM

First I'd like to thank unknown, this api is superb.  I have a question regarding the order of events.  I am trying to add smf to a current site.  I'm not exactly sure what order some of these functions should be called in.  So lets try this example:

I am using the login form from SSI to log the user in.  Now, when I user comes to one of the main site pages [not a forum page] I belive I should be using some combination of these three functions, but I'm not exactly sure which order they should appear in

smf_loadSession();
smf_setLoginCookie(60, addslashes(), , false);
smf_authenticateUser();

Note that a user may be a guest or a member when entering the main site depending on weither or not they have logged in, either from the forum or from the main site.

Can you shed some light on the proper use of these functions?

Thanks,
Andrew
Title: Re: A new tool is available for download. (smf_api.php)
Post by: [Unknown] on September 07, 2005, 02:20:18 AM
It's not a good idea to use this and SSI.php at the same time, I'm afraid.

The order you have listed is fine, though.

-[Unknown]
Title: Re: A new tool is available for download. (smf_api.php)
Post by: jonyo on October 13, 2005, 07:20:31 PM
Any news on when the release of smf_api.php 1.1 is?  (or is it already out there somewhere?)  Been having trouble getting the login to work..  It sets the cookie, it authenticates, it even sets up the session, but for some reason I'm not logged in when I go over to the board.  I have local cookies off and sub whatever cookies on.  If I am already loged into the board, it actually logs me out by going to the page that uses smf_api...  I am guessing these issues will be resolved with the new version?

Thanks,
-Jon
Title: Re: A new tool is available for download. (smf_api.php)
Post by: J. S. on January 10, 2006, 10:07:11 AM
I have Coppermine installed and running well with SMF. My question is: can I use smf_api.php to show in action=who peoples who are on the gallery? If not, is there any other way to do that?
Title: Re: A new tool is available for download. (smf_api.php)
Post by: spun2u on April 08, 2006, 01:54:58 PM
Okay, I've read several threads (including this one) here referring to intergrating two sites, but it's not clicking for me. I'm abit of a newbie to smf but I do like it so far. My issue is I need to somehow get smf to use the username/password details from another site on a different server. This other existing site is not a CMS site, but a BT tracker site. I'm going to use the smf forum as a help and general discussion area for the tracker site. I just can't figure out the best way to get smf to use the user details from the tracker.

Is the smf api the way to go?

Could anyone here take some time to point me in the right direction to achieving this? I love messing around with these scripts and have learned alot in the process but with this task I'm stumped.


Kev
Title: Re: A new tool is available for download. (smf_api.php)
Post by: obelouisque on June 01, 2006, 06:36:24 AM
Hi there,

I have just installed SMF (1-0-7) on my website and before using it online I tried the smf_api.php to login and logout users from other pages of my site. I use the classic functions:

require_once('smf_api.php');
smf_setLoginCookie( 3600, $user, $passwd, false );
smf_authenticateUser();
smf_loadSession();
smf_logOnline();

That works perfectly when I try it locally (with a local replicate of my site) but I can't manage to make it working online, the cookie is just not sent. But my username appear on the forum page as if I were logged in. I can't figure out what is going wrong????????
Any idea would be welcome!!!

Thanks,
louis
Title: Re: A new tool is available for download. (smf_api.php)
Post by: BURN3R on June 30, 2008, 07:42:36 PM
Sorry for digging up an old topic but is this tool still updated / supported?
I'm having trouble using it with my 1.1.5 SMF install, Ive searched a lot and found a couple of versions of this file around and not sure which one I should be using, if any.
Title: Re: A new tool is available for download. (smf_api.php)
Post by: rewen on November 15, 2008, 10:15:13 AM
I am also wonder what I should be using. I have SMF 1.1.7 and need to be able to log users in and out from my own custom site.

I just switched from IPB to SMF.. IPB had an amazing API (though it was 3rd party). My site needs to be able to tell if a user is logged in, what user group they are in, how many private messages they have, how many members and guests are online, the member count, post count, newest member, current bdays, etc.

Any suggestions?

The problem with this API is that after I set the cookie it logs me out of the forum. So I log out back into the forum but then it logs me out of the custom site. The cookies must be different and won't authenticate. I am not under a subdomain or anything.

Here is my test script (the *entire* thing):

<?

require_once("/var/www/vhosts/my-site.com/httpdocs/smf/smf_api.php");

if (smf_authenticateUser() === false) {
echo "<p>Not logged in. Setting login cookie. Reload page to authenticate cookie and login.</p>\n";

if (smf_setLoginCookie(3600, "rewen", "06646c1e194ac42a0b30c94f2b648a9a2967c9f9", true) === false) {
echo "<p>Setting of cookie failed</p>\n";
}
} else {
smf_loadSession();
smf_logOnline("Logged in from test script");

echo "<p>Cookie found and authenticated. Logged in</p>\n";

print_r ($smf_user_info);
}
?>
Title: Re: A new tool is available for download. (smf_api.php)
Post by: 青山 素子 on November 15, 2008, 10:52:22 AM
Although the API is still valid for 1.1, I suggest you look into using the integration hooks (check the bridges board) and SSI.php. You can get all the user info by including SSI.php.