Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

A new tool is available for download. (smf_api.php)

Started by [Unknown], September 12, 2004, 07:39:35 PM

Previous topic - Next topic


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:

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.



I've just updated it once more with something rather critical: session support ;).


Tony Reid

Hey cant wait to play with this tonight :)

Tony Reid


well features over the SSI other than u sited,fighting over output buffering
what can we do with this???
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.


I have integrate this code at the first part of of coppermine gallery



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

Notice: Constant ¨Òë 6 already defined in /home/httpd/vhosts/ on line 85

Notice: A session had already been started - ignoring session_start() in /home/httpd/vhosts/ on line 154

Fatal error: Call to undefined function: db_affected_rows() in /home/httpd/vhosts/ 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 -_-


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.



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?
If you can't join 'em, beat 'em ...


I used this to logout.

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

SMF since 2004 <3


No, session destroy is not what you want.  What Leah posted should work.



If you can't join 'em, beat 'em ...


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.
If you can't join 'em, beat 'em ...


From smf_api.php:
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.



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 :)
If you can't join 'em, beat 'em ...


Is the smf_api compatible with SMF 1.0? I've upgraded and it doesn't seem to work :(
If you can't join 'em, beat 'em ...


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.)



Ah ... somehow registering users does work, butt logging on and off doesn't.
I'll try upgrading first.

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?
If you can't join 'em, beat 'em ...


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.

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 ???

* Shedman is getting a little frustrated ::)
If you can't join 'em, beat 'em ...


AH!   Yes, this could also be the cause of an issue with the "who's online" module for the Mambo-SMF bridge...


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."


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 ???

* Shedman 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.