Installation and Configuration
A Simple Tutorial
Installation and Configuration
Installing and Configuring the IPB SDK should be very easy. Firstly, extract the files from the compressed file you downloaded to your hard drive, preserving the original file structure. Open up the ipbsdk_conf.inc.php file and look for the following settings:
The Root Path to your IPB installation.
You must use a trailing slash. A full path is strongly recommended
i.e /var/www/apache but a relative path can usually be used
without problems.
*/
$root_path = '/path/to/your/invision/board';
/*
The URL to your board.
You are not required to use a trailing slash.
*/
$board_url = 'http://localhost';
You will need to change these settings to your board settings. You may also wish to change your SDK language pack and board version settings if applicable. These settings can also be found ipbsdk_conf.inc.php.
After configuring IPB SDK, upload ipbsdk_ conf.inc.php, ipbsdk_class.inc.php and the lib folder. It's up to you where you upload it, as long as your scripts can access it. A recommend location is a folder named ipbsdk in your web root.
You do not need to modify any IPB folders.
A Simple Tutorial
Programming with the IPB SDK is really easy, especially if you already know some PHP. This tutorial will take you through building a very simple script, which will display a page, only if the user is logged in, and will produce an error if the current user isn't logged in, using PHP and the IPB SDK.
.php is usually the default file extension for PHP-enabled files, so create a file called tutorial.php. If .php isn't your default file extension, or you wish to have a different filename, feel free to change this.
All PHP code must contain the following lines of code:
?>
All PHP code should go between the opening tag <?php and the closing tag ?>. If you are not a expert in PHP, or wish to learn the basics before continuing, head over to PHP.net.
The first thing we want to do is to include or require the IPB SDK file. This line must be present in all of your scripts which utilitize the IPB SDK. Add below <?php the following code:
require_once "ipbsdk_class.inc.php";
$SDK =& new IPBSDK();
You may have to modify the require_once statement to point at the location of your main IPB SDK file.
Your now ready to do the fun bit. IPB SDK comes with a built-in function which allows you to tell if the current user is logged in. The function is is_loggedin(). We need to use a bit of PHP, and this function to show different content to registered users and guests. Below the require_once line add:
// Code for logged in users goes here
} else {
// Code for guests goes here
}
The code above should be pretty self-explanatory. Code between the first set of curly braces will be executed if the user is logged in, the second set of curly braces holds the code which will be executed if we have a guest. You can use the power of PHP to do all kinds of stuff, but we're just going to build a simple member-only page.
After // Code for logged in users goes here on a new line, we want to add a echo statement. This is how PHP sends output to the browser. If you wish you may exit out of PHP, and send HTML directly, without the echo statement. Add the following code:
Member Only Page goes here';
Feel free to change this to anything else, or put any HTML here you wish. Now do the same with the guests, but change the text to the guest page:
If you have followed all the instructions correctly, you should have the following code:
// Load and Start IPB SDK
require_once "ipbsdk_class.inc.php";
$SDK =& new IPBSDK();
if ($SDK->is_loggedin()) {
// Code for logged in users goes here
echo 'You are logged in!!!
Member Only Page goes here';
} else {
// Code for guests goes here
echo 'You are not logged in!';
}
?>
Save this file, and upload it to your webspace, along with IPB SDK's class and configuration file. As long as IPB SDK is properly configured, you should now have a fully working member-only page! For a set of pre-made scripts, look in the examples folder of the distribution package.
If you wish to develop more advanced scripts, not found in the Examples, check out the PHP Manual at PHP.net, and the IPB SDK Function Reference.
User Contributed Notes
Documentation Generated at Sat, 16 Apr 2005 07:36:35 -0700
Find the latest version at http://ipbsdk.sourceforge.net
Renegade
Just a quick hint, i found out (from looking at ipbsdk's site) that if your using a $SDK function instead one of your custom functions that you should use $GLOBALS['SDK']->
cow
If you are logged in on your board, but you appear as a guest on your main site, it is likely your cookies are set up incorrectly. In the cookie settings section of the Admin CP, blank out all paths except from the cookie for the domain. For the cookie domain, enter .yourdomain.com, where yourdomain.com is your domain. This will make the cookies avaliable to the whole domain and subdomains. Hope this helps someone!