• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Invision Power Board (IPB) Integration

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
26 posts • Page 1 of 2 • 1, 2

Postby HeroicLife » Tue Jan 09, 2007 10:56 pm

A number of people have asked for IPB support. Out integration is rather messy, but it works. Feel free to clean it up and repost it below.

Note that we added a custom profile field to allow members to customize their nick. Remove that code if you don't do that.


mod_chat.php (in modules folder):

Code: Select all
<?php
//=====================================
// Define class, this must be the same
// in all modules
//=====================================

class module
{
   //=====================================
   // Define vars if required
   //=====================================

   var $ipsclass;
   var $class  = "";
   var $module = "";
   var $html   = "";
   
   var $result = "";
   
   //=====================================
   // Constructer, called and run by IPB
   //=====================================
   
   function run_module()
   {
      //=====================================
      // Do any set up here, like load lang
      // skin files, etc
      //=====================================
      
      $this->ipsclass->load_language('lang_boards');
        $this->ipsclass->load_template('skin_boards');
      
      //=====================================
      // Set up structure
      //=====================================
      
      switch( $this->ipsclass->input['cmd'] )
      {
         case 'dosomething':
            $this->do_something();
            break;
            
         default:
            $this->do_something();
            break;
      }
      
      print $this->result;
      exit();
   }
   

   function do_something()
   {


      if ($this->ipsclass->vars['phpfreechat_must_login'] == 'Y')
      {
        //Only allow logged-in members to use this module
        if (!($this->ipsclass->member['id']))
        {
          //Comment this to allow anonymous users
          $this->ipsclass->Error(array (LEVEL => 1, MSG => 'no_permission'));
          return;
        }
      }

        //Since the Forum and chat use slightly different domain names
        //we have to set a cookie for a domain that is accessible to chat
        setcookie('ipbSessionId',$_COOKIE['session_id'],time()*60,'/');
        header('Location: http://www.objectivismonline.net/chat/chat.php?ipbSessionId='.$this->ipsclass->sess->session_id);
        exit();
   }
}


?>

This is the top PHP section from chat.php, or the chat page (formerly index.php). Index.php should point to http://FORUMURL/index.php?automodule=chat

Code: Select all
<?php
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
session_start();
$params = array();

if (isset($_SESSION['ipbMemberName']) && (strtoupper($_SESSION['ipbMemberName']) != "GUEST"))
{
  $ipbMemberName = $_SESSION['ipbMemberName'];
  $params["nick"] = $ipbMemberName;  // setup the initial nickname
}
elseif (isset($_COOKIE['ipbSessionId']) || (isset($_GET['ipbSessionId'])))
{
  //Read the cookie that was set by the forum add-on module
  if (isset($_COOKIE['ipbSessionId']))
  {
     $ipbSessionId = $_COOKIE['ipbSessionId']; 
  }
  else
  {
     $ipbSessionId = $_GET['ipbSessionId']; 
  }

  //----------------------------------------------------------
  //Read IPB Global settings, to get DB connection info. Then Connect to DB
  require_once ("../forum/conf_global.php");
  $dbhost=$INFO['sql_host'];
  $dbuser=$INFO['sql_user'];
  $dbpasswd=$INFO['sql_pass'];
  $dbname=$INFO['sql_database'];
  $tblPrefix=$INFO['sql_tbl_prefix'];
  $conn = mysql_connect($dbhost,$dbuser,$dbpasswd);
  if (!$conn) { echo "Connection impossiblen"; exit; }
  @mysql_select_db($dbname) or die( "Unable to select database");

  //----------------------------------------------------------
  //Use the session id, from the cookie to read IPB's session table
  //Read in the Member Id, Name and Group
  $query = "select member_id, member_name, member_group from ".$tblPrefix."sessions where id = ";
  $query .= "'".$ipbSessionId ."'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());

  $row = mysql_fetch_array($result, MYSQL_NUM);
  mysql_free_result($result);
  $ipbMemberId= $row[0];
  $ipbMemberName= $row[1];
  $ipbMemberGroup= $row[2];
  $isadmin = false; // false by default

  //For now, I'm hard-coding group=5 (BANNED)
    if ($ipbMemberGroup == 4 || $ipbMemberGroup == 6) {
       // Is Admin or Moderator
      $isadmin = true;
} elseif ($ipbMemberGroup == 5) {
     die( "Chat is not available. Try again later. ");
}


  if ($ipbMemberId)
  {
    //----------------------------------------------------------
    //Use the member Id to read the 10th custom profile field
    //(will vary with installation)
    //On our site, this contains the preferred Nick
    $query = "select field_10 from ".$tblPrefix."pfields_content where member_id = ";
    $query .= $ipbMemberId ;

    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    $row = mysql_fetch_array($result, MYSQL_NUM);
    mysql_free_result($result);
    $ipbChatNick= $row[0];
  }

  //----------------------------------------------------------
  //Get the user's IP, to check against the banned list
  $userIPaddress = $_SERVER['REMOTE_ADDR'];
  $query = "select count(*) from ".$tblPrefix."banfilters ";
  $query .= " where ban_type = 'ip' and ban_content = ";
  $query .= "'".$userIPaddress ."'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  $row = mysql_fetch_array($result, MYSQL_NUM);
  mysql_free_result($result);
  if ($row[0] > 0)
  {
    die( "Chat is not available. Try again later.");
  }

  //----------------------------------------------------------
  //All done with database access.
  mysql_close($conn);
  //----------------------------------------------------------
  if (isset($ipbChatNick) && ($ipbChatNick!=""))
  {
    $defaultNick = $ipbChatNick;
  }
  else
  {
    $defaultNick = $ipbMemberName;
  }
}
else
{
//No session variables and no Cookie with session id
//Indicates attempt at direct access. So, re-route via entry-point URL
// disabled by David because of problems
//echo "No session variables found.  Please go to http://www.objectivismonline.net/chat";
//  header('Location: http://forum.objectivismonline.net/index.php?automodule=chat');
//  exit;
}

$params["isadmin"] = $isadmin;
if (isset($defaultNick) && ($defaultNick!=""))
{
  //$params["nick"] = $defaultNick;
  //The line below allows names with French-like characters
   $params["nick"] = iconv("UTF-8", "ISO-8859-1", $defaultNick);
}
else
{
   $params["nick"] = "egoist".rand(1,10);
}

//---------------------------------------------------
//SELECT g_is_supmod FROM ibf_groups where g_id = ?
//A value of 1 would mean Moderator or Admin.
if (isset($_GET['anon']) && (strtoupper($_GET['anon']) != "moderator"))
{
  $params["nick"] = "egoist".rand(11,15);
}


$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat

//Override the default list of censored words, so that sex is sex, not ***
$params["proxies_cfg"]["censor"]["words"] = array("fuck","bitch");

//$params["theme"] = "blune";
$params["channels"] = array("Lobby");
$params["title"] = "ObjectivismChat";
$params["quit_on_closedwindow"] = true;
//$params["refresh_delay"] = "2000";
$params["showsmileys"] = false;


$chat = new phpFreeChat( $params);
?>
Last edited by HeroicLife on Thu Mar 06, 2008 12:03 am, edited 1 time in total.
HeroicLife
Member
 
Posts: 17
Joined: Tue Feb 21, 2006 8:55 pm
Top

Postby ali » Mon Jan 22, 2007 10:29 pm

Please correct these errors:

'isadmin' parameter must be a boolean

how can i correct this error and how can i use these files, link chat.php?
ali
New member
 
Posts: 1
Joined: Mon Jan 22, 2007 2:59 pm
Top

Postby peps » Tue May 01, 2007 3:13 pm

It does not work
peps
New member
 
Posts: 2
Joined: Tue May 01, 2007 7:56 am
Top

Postby mcmcomput » Mon May 21, 2007 6:13 am

I am trying to do the same thing, anyone have this running?
mcmcomput
New member
 
Posts: 1
Joined: Mon May 21, 2007 6:05 am
Top

Postby alex_ts » Wed Aug 01, 2007 12:14 pm

It works. Thanks!
alex_ts
New member
 
Posts: 1
Joined: Wed Aug 01, 2007 12:06 pm
Top

Postby atsaunier » Sun Nov 11, 2007 2:16 am

im getting a blank page...... what could i be doing wrong?
atsaunier
New member
 
Posts: 4
Joined: Sun Nov 11, 2007 2:15 am
Top

Postby atsaunier » Mon Nov 12, 2007 6:22 pm

anyone.....is this site still live?
atsaunier
New member
 
Posts: 4
Joined: Sun Nov 11, 2007 2:15 am
Top

Postby OldWolf » Tue Nov 13, 2007 11:58 pm

A blank page could be caused by just about anything... I think you're going to need to provide more info.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby atsaunier » Wed Nov 14, 2007 1:28 am

www.winxperts.net/forums/index.php?automodule=chat if you need me to past the contents of both files above to make sure i didnt do nothing wrong i can do that, just let me know
atsaunier
New member
 
Posts: 4
Joined: Sun Nov 11, 2007 2:15 am
Top

Postby OldWolf » Thu Nov 15, 2007 11:58 pm

Lets go ahead and see them. I'm not sure I can help since I don't know IPB that well, but go for it. :)
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby atsaunier » Fri Nov 16, 2007 11:01 pm

Chat.php
Code: Select all
<?php
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
session_start();
$params = array();

if (isset($_SESSION['ipbMemberName']) && (strtoupper($_SESSION['ipbMemberName']) != "GUEST"))
{
  $ipbMemberName = $_SESSION['ipbMemberName'];
  $params["nick"] = $ipbMemberName;  // setup the initial nickname
}
elseif (isset($_COOKIE['ipbSessionId']) || (isset($_GET['ipbSessionId'])))
{
  //Read the cookie that was set by the forum add-on module
  if (isset($_COOKIE['ipbSessionId']))
  {
     $ipbSessionId = $_COOKIE['ipbSessionId']; 
  }
  else
  {
     $ipbSessionId = $_GET['ipbSessionId']; 
  }

  //----------------------------------------------------------
  //Read IPB Global settings, to get DB connection info. Then Connect to DB
  require_once ("../conf_global.php");
  $dbhost=$INFO['sql_host'];
  $dbuser=$INFO['sql_user'];
  $dbpasswd=$INFO['sql_pass'];
  $dbname=$INFO['sql_database'];
  $tblPrefix=$INFO['sql_tbl_prefix'];
  $conn = mysql_connect($dbhost,$dbuser,$dbpasswd);
  if (!$conn) { echo "Connection impossiblen"; exit; }
  @mysql_select_db($dbname) or die( "Unable to select database");

  //----------------------------------------------------------
  //Use the session id, from the cookie to read IPB's session table
  //Read in the Member Id, Name and Group
  $query = "select member_id, member_name, member_group from ".$tblPrefix."sessions where id = ";
  $query .= "'".$ipbSessionId ."'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());

  $row = mysql_fetch_array($result, MYSQL_NUM);
  mysql_free_result($result);
  $ipbMemberId= $row[0];
  $ipbMemberName= $row[1];
  $ipbMemberGroup= $row[2];
  $isadmin = false; // false by default

  //For now, I'm hard-coding group=5 (BANNED)
    if ($ipbMemberGroup == 4 || $ipbMemberGroup == 6) {
       // Is Admin or Moderator
      $isadmin = true;
} elseif ($ipbMemberGroup == 5) {
     die( "Chat is not available. Try again later. ");
}


  if ($ipbMemberId)


  //----------------------------------------------------------
  //Get the user's IP, to check against the banned list
  $userIPaddress = $_SERVER['REMOTE_ADDR'];
  $query = "select count(*) from ".$tblPrefix."banfilters ";
  $query .= " where ban_type = 'ip' and ban_content = ";
  $query .= "'".$userIPaddress ."'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  $row = mysql_fetch_array($result, MYSQL_NUM);
  mysql_free_result($result);
  if ($row[0] > 0)
  {
    die( "Chat is not available. Try again later.");
  }

  //----------------------------------------------------------
  //All done with database access.
  mysql_close($conn);
  //----------------------------------------------------------
  if (isset($ipbChatNick) && ($ipbChatNick!=""))
  {
    $defaultNick = $ipbChatNick;
  }
  else
  {
    $defaultNick = $ipbMemberName;
  }
}
else
{
//No session variables and no Cookie with session id
//Indicates attempt at direct access. So, re-route via entry-point URL
// disabled by David because of problems
//echo "No session variables found.  Please go to http://www.winxperts.net/forums/chat";
//  header('Location: http://winxperts.net/forums/index.php?automodule=chat');
//  exit;
}

$params["isadmin"] = $isadmin;
if (isset($defaultNick) && ($defaultNick!=""))
{
  //$params["nick"] = $defaultNick;
  //The line below allows names with French-like characters
   $params["nick"] = iconv("UTF-8", "ISO-8859-1", $defaultNick);
}
else
{
   $params["nick"] = "egoist".rand(1,10);
}

//---------------------------------------------------
//SELECT g_is_supmod FROM ibf_groups where g_id = ?
//A value of 1 would mean Moderator or Admin.
if (isset($_GET['anon']) && (strtoupper($_GET['anon']) != "moderator"))
{
  $params["nick"] = "egoist".rand(11,15);
}


$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat

//Override the default list of censored words, so that sex is sex, not ***
$params["proxies_cfg"]["censor"]["words"] = array("fuck","bitch");

//$params["theme"] = "default";
$params["channels"] = array("Lobby");
$params["title"] = "ObjectivismChat";
$params["quit_on_closedwindow"] = true;
//$params["refresh_delay"] = "2000";
$params["showsmileys"] = false;


$chat = new phpFreeChat( $params);
?>

mod_chat.php

Code: Select all
<?php
/*
+--------------------------------------------------------------------------
|   Invision Power Board
|   =============================================
|   by Matthew Mecham
|   (c) 2001 - 2006 Invision Power Services, Inc.
|   http://www.invisionpower.com
|   =============================================
|   Web: http://www.invisionboard.com
|   Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|   > $Date: 2005-10-10 14:03:20 +0100 (Mon, 10 Oct 2005) $
|   > $Revision: 22 $
|   > $Author: matt $
+---------------------------------------------------------------------------
|
|   > MODULE FILE (EXAMPLE)
|   > Module written by Matt Mecham
|   > Date started: Thu 14th April 2005 (17:59)
|
+--------------------------------------------------------------------------
*/

//=====================================
// Define class, this must be the same
// in all modules
//=====================================

class module
{
   //=====================================
   // Define vars if required
   //=====================================
   
   var $ipsclass;
   var $class  = "";
   var $module = "";
   var $html   = "";
   
   var $result = "";
   
   //=====================================
   // Constructer, called and run by IPB
   //=====================================
   
   function run_module()
   {
      //=====================================
      // Do any set up here, like load lang
      // skin files, etc
      //=====================================
      
      $this->ipsclass->load_language('lang_boards');
        $this->ipsclass->load_template('skin_boards');
      
      //=====================================
      // Set up structure
      //=====================================
      
      switch( $this->ipsclass->input['cmd'] )
      {
         case 'dosomething':
            $this->do_something();
            break;
            
         default:
            $this->do_something();
            break;
      }
      
      print $this->result;
      
      exit();
   }
   
   //------------------------------------------
   // do_something
   //
   // Test sub, show if admin or not..
   //
   //------------------------------------------
   
          function do_something()
    {


      if ($this->ipsclass->vars['phpfreechat_must_login'] == 'Y')
      {
        //Only allow logged-in members to use this module
        if (!($this->ipsclass->member['id']))
        {
          //Comment this to allow anonymous users
          $this->ipsclass->Error(array (LEVEL => 1, MSG => 'no_permission'));
          return;
        }
      }

        //Since the Forum and chat use slightly different domain names
        //we have to set a cookie for a domain that is accessible to chat
        setcookie('ipbSessionId',$_COOKIE['session_id'],time()*60,'/');
        header('Location: http://www.winxperts.net/forums/chat/chat.php?ipbSessionId='.$this->ipsclass->sess->session_id);
        exit();
    }
}


?>
atsaunier
New member
 
Posts: 4
Joined: Sun Nov 11, 2007 2:15 am
Top

Postby drvixx » Mon Feb 25, 2008 7:32 pm

does the code in the first post work?

as i dont have a 'modules' folder, where would i put the mod_chat.php?!?!

I really need this chat to work with IPB, as we migrate next week!
Last edited by drvixx on Mon Feb 25, 2008 7:41 pm, edited 1 time in total.
drvixx
New member
 
Posts: 4
Joined: Fri Feb 22, 2008 5:10 pm
Top

Postby HeroicLife » Thu Mar 06, 2008 12:00 am

Yes, it works fine - we've been using it for years: http://www.objectivismonline.net/chat

There is a modules folder in the root forum directory.
HeroicLife
Member
 
Posts: 17
Joined: Tue Feb 21, 2006 8:55 pm
Top

Postby vicki » Sun Mar 09, 2008 3:24 am

Heroic, maybe you can help me. I saw your site is running the same version of IPB as mine is. However, I think I must be doing something very wrong. I first cut the top section and pasted it into a new file called mod_chat.php. This file did not exist in my modules directory.

Then I went into my chat directory, which is off my forums root, and editted the index.php file. I removed the existing PHP information at the top of the file and I pasted what you show above.

When I hit the url: http://myurlhere.com/index.php?automodule=chat

I get this error.

Warning: run_loader(C:Inetpubforums/modules/mod_chat.php): failed to open stream: Permission denied in C:Inetpubforumsmodulesmodule_loader.php on line 62

When I try to hit it directly, I get this error:

Notice: Undefined variable: isadmin in C:Inetpubforumschatindex.php on line 110

In my IPB admin, there is nothing about chat and I don't have a tab for it in my user forums. I don't really understand how to add these things.

Probably many other people in here are php dunces like me.

Can you please help tell me what I am doing wrong?
vicki
New member
 
Posts: 7
Joined: Sun Mar 09, 2008 3:17 am
Top

Postby vicki » Sun Mar 09, 2008 3:55 am

Now, after making the url change in the mod_chat.php, I got that bolean error:



Notice: Undefined variable: isadmin in C:Inetpubforumschatchat.php on line 110

Please correct these errors:

'isadmin' parameter must be a boolean



I am running IIS 6. Does that matter?
vicki
New member
 
Posts: 7
Joined: Sun Mar 09, 2008 3:17 am
Top

Next

Post a reply
26 posts • Page 1 of 2 • 1, 2

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 5 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub