Valhalla Legends Forums Archive | Web Development | [PHP] Invision Board API

AuthorMessageTime
AssassinRC
This is a lengthy code sample, so I won't post it directly in the forums, nor will I post it until I figure out if anyone on these forums would find it useful. The Invision Board API I wrote connects any web page you are running to the IPB forum backend, making it possible to only show sections to specific member groups, retrieve live stats, and code your own sections that can be fully integrated with your members table. It's an amazing script for an amazing forum system, and i'd be more than happy to share the latest updated version I coded for 1.3 Final. An example of the API in action can be seen on the Royal Council home page: http://www.royal-council.com.
November 29, 2003, 10:58 AM
j0k3r
For one thing, thanks for all the PHP snippets everywhere, it's fun to read through and learn off them.

On another note, nice site man...
November 29, 2003, 12:36 PM
AssassinRC
Hehe no problem. A lot of vL seem to prefer ASP over PHP, but for my needs PHP was the easiest to learn and provided me with all of the functions I needed to achieve my goals. I will get the API packaged and ready.
November 29, 2003, 12:49 PM
AssassinRC
This is the API v5.0 with the standard upgraded main.php file. I may have missed a few edits, but I did my best. If users are interested in exporting a calendar, or using the welcome panel function I wrote -- ask me and I will provide the code. The code I have written is currently formatted specifically for the {RC} site so I left it out, but it wouldn't take much to convert it.

Download IPB API v5.0 HERE: http://www.royal-council.com/Downloads/APIv50.zip

I add new functions to this quite often. If anyone take interest to this i'd be more than willing to share.

There's also a reference file included that provides an example of the functions on one page, so you can see which ones are best suited to your needs prior to implementation. Anyone who is interested in coding on the IPB backend should also look at Cowwebdesign's SSIPlus+ and IPB SDK libraries, available at the links below.

IPB SDK: http://mods.ibplanet.com/db/?mod=1791
SSIPlus+ : http://mods.ibplanet.com/db/?mod=1174

If anyone wants to take a basic crack at the Welcome Panel code, it's posted below:
[code]function welcomepanel($type = 0) {

   GLOBAL $DB,$ibforums,$std,$HTTP_SERVER_VARS,$HTTP_USER_AGENT;

   if ($ibforums->member['id'] > 0) {
         $DB->query("SELECT * FROM `ibf_members` WHERE `id` = {$ibforums->member['id']}");
         $member = $DB->fetch_row();
         $DB->query("SELECT `starter_id` AS id, `starter_name` AS name, COUNT(*) AS `num` FROM `ibf_topics` GROUP BY id ORDER BY num DESC LIMIT 1");
         $row = $DB->fetch_row();
         $data['tt_id'] = $row[id];
         $data['tt_name'] = $row[name];
         $data['tt_num'] = $row[num];
         $DB->query("SELECT `id`,`name`,`posts` FROM `ibf_members` WHERE 1 ORDER BY `posts` DESC LIMIT 1");
         $row = $DB->fetch_row();
         $data['tp_id'] = $row[id];
         $data['tp_name'] = $row[name];
         $data['tp_num'] = $row[posts];
         $DB->query("SELECT COUNT(DISTINCT(t.tid)) as tcnt, COUNT(DISTINCT(p.pid)) as pcnt FROM ibf_posts p, ibf_topics t WHERE p.post_date < ".time()." AND p.post_date > ".$ibforums->member['last_visit']." AND p.topic_id=t.tid");
         $row = $DB->fetch_row();
         $data['topics_since'] = $row[tcnt];
         $data['posts_since'] = $row[pcnt];
         $DB->query("SELECT * FROM ibf_stats");
         $data['stats'] = $DB->fetch_row();
         $data['stats']['TOTAL_POSTS'] = $data['stats']['TOTAL_TOPICS'] + $data['stats']['TOTAL_REPLIES'];
         $data['lastv'] = $std->get_date2($ibforums->member['last_visit'], LONG);
         $data['time'] = $std->get_date2(time(), LONG);
         $data['avatar2'] = $member['avatar'];
         $name1 = $member['name'];
         if (ereg("http://", $member['avatar'], $urlmatch)) {
            $data['avatar'] = "<img src='".$member['avatar']."' width='60' height='60'>";
         } elseif (ereg("upload:", $member['avatar'], $uploadmatch)) {
            $avatar = split(":", $member['avatar']);
            $data['avatar'] = "<img src='{$ibforums->vars['board_url']}/uploads/".$avatar[1]."' width='60' height='60'>";
} elseif ($member['avatar'] == "noavatar") {
            $data['avatar'] = "<img src='{$ibforums->vars['board_url']}/html/avatars/noavatar.gif' width='60' height='60'>";
} elseif ($member['avatar'] == "") {
            $data['avatar'] = "<img src='{$ibforums->vars['board_url']}/html/avatars/noavatar.gif' width='60' height='60'>";
         } else {
            $data['avatar'] = "<img src='{$ibforums->vars['board_url']}/html/avatars/".$member['avatar']."' width='60' height='60'>";
      }

      } else {
         $data['time'] = $std->get_date2(time(), LONG);
         $today = mktime (0,0,0,date(M,time()),date(D,time()),date(Y,time()));
         $yestdate= $today - 86400;
         $DB->query("SELECT COUNT(DISTINCT(t.tid)) as gtcnt, COUNT(DISTINCT(p.pid)) as gpcnt FROM ibf_posts p, ibf_topics t WHERE p.post_date < ".time()." AND p.post_date > ".$today." AND p.topic_id=t.tid");
         $row = $DB->fetch_row();
         $data['guest_topics_since'] = $row[gtcnt];
         $data['guest_posts_since'] = $row[gpcnt];

      }[/code]

WARNING: Also note that I do recommend using the SDK over the API! It's more widely supported and provides a lot better functionality for advanced coders. This is a very simple setup recommended to starting integraters! :D
November 29, 2003, 1:00 PM
Crypticflare
Great job with the API.. but I've run into a snag setting up my ref.php file, it seems its giving me permission denied on some of the stuff on there I'll quote one.

[code]Function Name::active()
Usage
echo active();

Print the online member stats!
Template :: active.html
Demo


Warning: fopen(/root/Fuze/forums/templates/active.html): failed to open stream: Permission denied in /home/crypticflare/www/Fuze/forums/main.php on line 94

Warning: filesize(): Stat failed for /root/Fuze/forums/templates/active.html (errno=13 - Permission denied) in /home/crypticflare/www/Fuze/forums/main.php on line 95

Warning: fread(): supplied argument is not a valid stream resource in /home/crypticflare/www/Fuze/forums/main.php on line 95

Warning: fclose(): supplied argument is not a valid stream resource in /home/crypticflare/www/Fuze/forums/main.php on line 96
[/code]

I've checked the CHMOD on the files, and it seems everythings in place, I also followed the config.php properly, I opened up the PHP file and line that seems to be the conflict, but I'm not seeing a resolution. Any input is welcomed.
December 5, 2003, 4:41 AM
Crypticflare
[Edit] Seemed to fix the problem, and the intergration is very dandy. I'm working with the SDK right now, and this stuff is quite amazing. Thanks again!
December 5, 2003, 4:30 PM
AssassinRC
Hehe, yeah i've been programming with the SDK lately as well. The API is easier for first time integraters with it's basic template sets. But the SDK is far more comprehensive for advanced integration. Good luck with both. :)
December 11, 2003, 8:01 PM

Search