Simple Machines Community Forum

Customizing SMF => Bridges and Integrations => Topic started by: Sunchaser on February 08, 2011, 02:41:37 PM

Title: Integrating a PHP game with SMF 1.x
Post by: Sunchaser on February 08, 2011, 02:41:37 PM
Hi, i need to integrate a game written in PHP with Smf. I looked into SSI.php but it seems there are functions to show statistics or read-only information.

I need to:

- Register automatically a user (already registered to the game) (now i do it by updating directly SMF tables)
- Assign/deassign automatically a (existing) profile to a user
- Deleting a smf user

Is there another set of API around beside SSI.php?

Thanks
Title: Re: Integrating a PHP game with SMF 1.x
Post by: NanoSector on February 08, 2011, 02:47:44 PM
Not really -- but some files DO have the ability to do what you said.

Take a look at the Function Database at Development.
Title: Re: Integrating a PHP game with SMF 1.x
Post by: Sunchaser on February 08, 2011, 02:55:47 PM
I've looked at those function but they seem not integration APIs,

I have read some more posts and seems i maybe have to use integration hooks? Is there around some examples on
how i can use them from a simple php file?

Thanks




Title: Re: Integrating a PHP game with SMF 1.x
Post by: NanoSector on February 08, 2011, 03:01:24 PM
Quote from: Sunchaser on February 08, 2011, 02:55:47 PM
I've looked at those function but they seem not integration APIs,

I have read some more posts and seems i maybe have to use integration hooks? Is there around some examples on
how i can use them from a simple php file?

Thanks
Those are indeed integration APIs. -- in fact, they are way more powerful.

Just require the file in your game, and use the desired function.
Title: Re: Integrating a PHP game with SMF 1.x
Post by: Sunchaser on February 08, 2011, 03:33:02 PM
I tried the following

<?php
define 
("SMF");
require 
"./Subs-Members.php";
deleteMembers'test_creaschema' );
?>



Gives an error like:

PHP Fatal error:  Call to undefined function isAllowedTo() in <cut>httpdocs/Sources/Subs-Members.php on line 138

(function isAllowed is in the security.php file.

I have some questions:

1) What's the difference between Subs-* files and other files, and which ones should i include?
2) Which one i should include to avoid missing functions errors?
3) security checks the script for authentication, how i am supposed to authenticate the script

Sorry for all these questions, if there is a link you can point me to i can try to address the problem myself

Thanks
Title: Re: Integrating a PHP game with SMF 1.x
Post by: NanoSector on February 08, 2011, 03:37:17 PM
The function db has links to descriptions.

You need to require security.php too then before including the other file.
Title: Re: Integrating a PHP game with SMF 1.x
Post by: Arantor on February 08, 2011, 07:22:08 PM
Just include SSI.php before including the other file which loads all the important parts of SMF like the query functions, the allowedTo stuff and so on.
Title: Re: Integrating a PHP game with SMF 1.x
Post by: Kindred on February 09, 2011, 03:23:15 PM
Also, consider using the integration_hook functions rather than native smf functions...