It is currently Wed Oct 18, 2017 8:54 am




 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: Integration with vBulletin 4
PostPosted: Wed Aug 25, 2010 11:10 pm 
Support Staff

Joined: Fri Nov 01, 2002 4:06 am
Posts: 43
Following instructions have been tested on vBulletin 4.0.6. It assumes that you are familiar with certain administrative tasks within vBulletin, e.g. creating templates, editing languages.

Chat Page Template

Create template "cb_chat" with the following content. (Styles & Templates | Style Manager | Add New Template) Replace "SITE_ID" with your account's Site ID.

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
   {vb:raw headinclude}
   <title>{vb:raw vboptions.bbtitle}</title>

   <vb:if condition="$vboptions['storecssasfile']">
      <link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}forumhome-rollup.css" />
   <vb:else />
   <link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}forumbits.css,forumhome.css,tagcloud.css" />
   </vb:if>

   <!--[if IE 6]><link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}forumbits-ie.css" /><![endif]-->
   <vb:if condition="$show['sidebar']">
   <script type="text/javascript" src="{vb:stylevar yuipath}/animation/animation-min.js?v={vb:raw vboptions.simpleversion}"></script>
   <script type="text/javascript">
      var sidebar_align = '{vb:raw show.sidebarposition}';
      var content_container_margin = parseInt('{vb:math {vb:stylevar forum_sidebar_width}+{vb:math {vb:stylevar padding}*2}}');
      var sidebar_width = parseInt('{vb:stylevar forum_sidebar_width}');
   </script>
   <script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-sidebar.js?v={vb:raw vboptions.simpleversion}"></script>
   </vb:if>

<script language="JavaScript" type="text/javascript">
<!--
   // if SWF is not located together with HTML, this must be defined and end with a "/"
   var sourceBase="http://host5.chatblazer.com/";
   var siteID="";

   var tagName = "script";
   document.write('<'+tagName+' language="JavaScript" type="text/javascript" src="'+sourceBase+'chatblazer.js"></'+tagName+'>');
//-->
</script>

   {vb:raw headinclude_bottom}
</head>
   <body>

   {vb:raw header}

   {vb:raw navbar}

   <div id="pagetitle">
      <h1>{vb:raw vboptions.bbtitle}</h1>
      <p id="welcomemessage" class="description">{vb:rawphrase welcome_to_the_x, {vb:raw vboptions.bbtitle}}</p>
   </div>

   <vb:if condition="$show['sidebar']">
   <div id="content_container"<vb:if condition="$show['sidebarposition'] == 'left'"> class="contentright"</vb:if>>
      <div id="content">
   </vb:if>
   <!-- main -->

   <div class="navlinks" style="height: 500px">
<vb:if condition="$userid > 0">

<script language="JavaScript" type="text/javascript">
<!--
   
   // if SWF and XML are on different domains, state its full path
   var mainConfig      = "SITE_ID/config.xml";
   var mainLang      = "";
   var mainSkin      = "";

   // username and password used for direct login only
   var directUsername   = "{vb:raw username}";
   var directPassword   = "{vb:raw password}";
   var roomPassword   = "";
   var roomID         = "";
   var roomName      = "";
   var privateChatCID   = "";

   // logoPath should be swf/png/jpg/gif, approximately 200x30
   // bgPath should be swf/png/jpg/gif, size will be stretched to the full background
   // bgColor if no background is desired
   var logoPath      = "";
   var bgPath         = "";
   var bgColor         = "";
   var barColor      = "";   // #336699

   // Size of ChatBlazer application in % or pixels
   var chatWidth      = "100%";
   var chatHeight      = "100%";

   // path of chat
   var flashPath = "ChatBlazer8"+(mainSkin?"_"+mainSkin:"")+".swf?cb=1";
   var flashVersion = "http://host5.chatblazer.com/version.php";

   var flashVars = "";

   function addParam(pname,pval) {
      if (typeof pval!="undefined" && pval) { flashVars = flashVars + "&"+pname+"=" + encodeURIComponent(pval); }
   }

   addParam("lang",mainLang);
   addParam("config",mainConfig);
   addParam("skin",mainSkin);
   addParam("username",directUsername);
   addParam("password",directPassword);
   addParam("roompass",roomPassword);
   addParam("roomid",roomID);
   addParam("roomname",roomName);
   addParam("privatechatcid",privateChatCID);
   addParam("logo",logoPath);
   addParam("bgpath",bgPath);
   addParam("bgcolor",bgColor);
   addParam("barcolor",barColor);

   if (navigator.appVersion.indexOf("MSIE") != -1) {
      addParam("isIE","1");
   }

   embedFlash(flashPath,chatWidth,chatHeight,"cbe8",sourceBase, "#000000", flashVars, flashVersion);

//-->
</script>

<vb:else />

Please log in before using the Chat feature.

</vb:if>
   </div>

   <!-- /main -->

   <!-- what's going on box -->
   <div id="wgo" class="collapse wgo_block">
      <h2>
      <span>{vb:rawphrase whats_going_on}</span>
      </h2>
      <div class="floatcontainer">
         {vb:raw template_hook.forumhome_wgo_pos1}
         <vb:if condition="$show['loggedinusers']">
         <!-- logged-in users -->
         <div id="wgo_onlineusers" class="wgo_subblock">
            <h3><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="{vb:rawphrase currently_active_users}" />{vb:rawphrase currently_active_users}</h3>
            <div>
               <p>{vb:rawphrase there_are_x_online, {vb:raw totalonline}} <span class="shade">{vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}</span></p>
               <p>{vb:rawphrase most_users_ever_online_was_x_y_at_z, {vb:raw recordusers}, {vb:raw recorddate}, {vb:raw recordtime}}</p>
               <ol class="commalist" id="wgo_onlineusers_list">
                  {vb:raw activeusers}
               </ol>
            </div>
         </div>
         <!-- end logged-in users -->
         </vb:if>
         {vb:raw template_hook.forumhome_wgo_pos2}
         <vb:if condition="$show['upcomingevents']">
         <div id="wgo_events" class="wgo_subblock">
            <h3><img src="{vb:stylevar imgdir_misc}/event.png" alt="{vb:rawphrase todays_events}" /><vb:if condition="$show['todaysevents']">{vb:rawphrase todays_events}<vb:else />{vb:rawphrase upcoming_events_for_the_next_x_days, {vb:raw vboptions.showevents}}</vb:if></h3>
            <ol>
               {vb:raw upcomingevents}
            </ol>
         </div>
         </vb:if>
         {vb:raw template_hook.forumhome_wgo_pos3}
         <vb:if condition="$show['birthdays']">
         <!-- today's birthdays -->
         <div id="wgo_birthdays" class="wgo_subblock">
            <h3><img src="{vb:stylevar imgdir_misc}/birthday.png" alt="{vb:rawphrase todays_birthdays}" />{vb:rawphrase todays_birthdays}</h3>
            <ol class="commalist">
               {vb:raw birthdays}
            </ol>
         </div>
         <!-- end today's birthdays -->
         </vb:if>
         {vb:raw template_hook.forumhome_wgo_pos4}
         <div id="wgo_stats" class="wgo_subblock">
            <h3><img src="{vb:stylevar imgdir_misc}/forum_stats.png" alt="{vb:rawphrase x_statistics, {vb:raw vboptions.bbtitle}}" />{vb:rawphrase x_statistics, {vb:raw vboptions.bbtitle}}</h3>
            <div>
               <dl>
                  <dt>{vb:rawphrase threads}</dt>
                     <dd>{vb:raw totalthreads}</dd>
                  <dt>{vb:rawphrase posts}</dt>
                     <dd>{vb:raw totalposts}</dd>
                  <dt>{vb:rawphrase members}</dt>
                     <dd>{vb:raw numbermembers}</dd>
                  <vb:if condition="$show['activemembers']">
                                                <dt>{vb:rawphrase active_members}</dt>
                                                         <dd>{vb:raw activemembers}</dd>
                                                </vb:if>
               </dl>
               <p>{vb:rawphrase welcome_to_our_newest_member_x, {vb:link member, {vb:raw newuserinfo}}, {vb:raw newuserinfo.username}}</p>
               {vb:raw template_hook.forumhome_wgo_stats}
            </div>
         </div>
         <div id="wgo_legend" class="wgo_subblock">
            <h3><img src="{vb:stylevar imgdir_misc}/legend.png" alt="{vb:rawphrase icon_legend}" />{vb:rawphrase icon_legend}</h3>
            <div>
               <dl id="icon_legends" class="icon_legends">
                  <dt><img src="{vb:stylevar imgdir_statusicon}/forum_new-16.png" alt="{vb:rawphrase new_posts_forum}" /></dt><dd>{vb:rawphrase new_posts_forum}</dd>
                  <dt><img src="{vb:stylevar imgdir_statusicon}/forum_old-16.png" alt="{vb:rawphrase no_new_posts_forum}" /></dt><dd>{vb:rawphrase no_new_posts_forum}</dd>
                  <dt><img src="{vb:stylevar imgdir_statusicon}/category-16.png" alt="{vb:rawphrase category_forum}" /></dt><dd>{vb:rawphrase category_forum}</dd>
                  <dt><img src="{vb:stylevar imgdir_statusicon}/forum_link-16.png" alt="{vb:rawphrase link_forum}" /></dt><dd>{vb:rawphrase link_forum}</dd>
               <vb:if condition="$vboptions['pt_hasprojectforums']">
                  <dt><img src="{vb:stylevar imgdir_statusicon}/project_new-16.png" alt="{vb:rawphrase project_forum}" /></dt><dd>{vb:rawphrase project_forum}</dd>
               </vb:if>
               </dl>
            </div>
         </div>
         {vb:raw template_hook.forumhome_wgo_pos5}
      </div>
   </div>
   <!-- end what's going on box -->

   {vb:raw ad_location.board_below_whats_going_on}
   <vb:if condition="$show['sidebar']">
      </div>
   </div>

   <div id="sidebar_container"<vb:if condition="$show['sidebarposition'] == 'left'"> class="sidebarleft"</vb:if>>
      <a id="sidebar_button_link" href="#">
         <vb:if condition="$show['sidebarposition'] == 'left'">
         <img id="sidebar_button" src="{vb:stylevar imgdir_misc}/tab-collapsed-left.png" alt="" />
         <vb:else />
         <img id="sidebar_button" src="{vb:stylevar imgdir_misc}/tab-collapsed.png" alt="" />
         </vb:if>
      </a>
      <ul id="sidebar">
         {vb:raw sidebar}
      </ul>
   </div>
   </vb:if>

   {vb:raw footer}
</body>
</html>


Chat Tab on Navbar

Create template "cb_chat_navbar" with the following content.
<vb:if condition="$vboptions['selectednavtab'] == 'chat'">
<li class="selected">
<a class="navtab" href="chat.php{vb:raw session.sessionurl_q}">{vb:rawphrase cb_chat}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="chat.php{vb:raw session.sessionurl_q}">{vb:rawphrase cb_chat}</a></li>
</vb:if>


Change Language

Add the following phrase. (Langauges & Phrases | Phrase Manager | Add New Phrase)
"cb_chat" -- Chat


Add Plugin

Create the plugin "cb_chat_hook". (Plugins & Products | Add New Plugin)

Hook Location: process_templates_complete
Title: cb_chat_hook
Exection Order: 5

if (THIS_SCRIPT == 'chat') {
   // set selected tab
   $vbulletin->options['selectednavtab'] = 'chat';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('cb_chat_navbar')->render();


Turn the plugin active. Click "Save Active Status".

Standard Chat Page

Create this page, e.g. chat.php, in the base directory of vBuletin.
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'chat');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('holiday');

// get special data templates from the datastore
$specialtemplates = array(
   'userstats',
   'birthdaycache',
   'maxloggedin',
   'iconcache',
   'eventcache',
   'mailqueue',
   'activeblocks',
);

// pre-cache templates used by all actions
$globaltemplates = array(
   'ad_forumhome_afterforums',
   'ad_board_below_whats_going_on',
   'block_blogentries',
   'block_cmsarticles',
   'block_newposts',
   'block_sgdiscussions',
   'block_tagcloud',
   'block_threads',
   'FORUMHOME',
   'forumhome_event',
   'forumhome_forumbit_level1_nopost',
   'forumhome_forumbit_level1_post',
   'forumhome_forumbit_level2_nopost',
   'forumhome_forumbit_level2_post',
   'forumhome_lastpostby',
   'forumhome_loggedinuser',
   'forumhome_moderator',
   'forumhome_subforumbit_nopost',
   'forumhome_subforumbit_post',
   'forumhome_subforumseparator_nopost',
   'forumhome_subforumseparator_post',
   'forumhome_markread_script',
   'forumhome_birthdaybit',
   'tag_cloud_link',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Chat';

// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTTA HERE... ###
($hook = vBulletinHook::fetch_hook('forumhome_complete')) ? eval($hook) : false;

$navbar = render_navbar_template(construct_navbits($navbits));

$pw = $vbulletin->session->vars['dbsessionhash'];

// var_dump($vbulletin->userinfo);
// var_dump($vbulletin->session);

$template = vB_Template::create('cb_chat');
$template->register_page_templates();
$template->register('navbar', $navbar);
$template->register('username', $vbulletin->userinfo['username']);
$template->register('password', $pw);
$template->register('userid', $vbulletin->userinfo['userid']);
print_output($template->render());

?>


Chat Authentication Script

This script is called by the ChatBlazer server to authenticate vBulletin sessions. Create this page, e.g. cb_auth.php, in the base directory of your vBulletin directory. Then specify the full URL in the ChatBlazer Admin, under the External User Datasource section. e.g. http://www.yourwebsite.com/forums/cb_auth.php.

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'chat_auth');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');

// ################### PRE-CACHE TEMPLATES AND DATA ######################


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

// var_dump($vbulletin->options);
// var_dump($vbulletin->session);

$reply = array();

$username = $_POST['username'];
$sessionhash = $_POST['password'];
$session_time = TIMENOW - $vbulletin->options['cookietimeout'] * 1000;

if ($username && $sessionhash) {
   $query = "SELECT * FROM " . TABLE_PREFIX . "session WHERE sessionhash = '"
      . $db->escape_string($sessionhash) . "' AND lastactivity > $session_time";

   $session = $db->query_first($query);
// if session exists:
// array(16) {
//      ["sessionhash"]=> "a39376a4f25a5fd3bef0b680418145de"
//      ["userid"]=> "1"
//      ["host"]=> "203.123.1.150"
//      ["idhash"]=> "422fcad723130a136972e02b095bc0d7"
//      ["lastactivity"]=> "1272429487"
//      ["location"]=> "/xnforum/chat.php"
//      ["useragent"]=> "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 (.NET C"
//      ["styleid"]=> "0"
//      ["languageid"]=> "0"
//      ["loggedin"]=> "2"
//      ["inforum"]=> "0"
//      ["inthread"]=> "0"
//      ["incalendar"]=> "0"
//      ["badlocation"]=> "0"
//      ["bypass"]=> "0"
//      ["profileupdate"]=> "0"
//   }
// if not found $session is false

   if ($session && $session['userid']) {
      $userinfo = fetch_userinfo($session['userid'], FETCH_USERINFO_ADMIN);
      // $userinfo is an array
      // check username
      if ($userinfo['username'] == $username) {
         // authenticated
         $reply['username'] = $userinfo['username'];
      }
   }
}

header('Content-Type: text/plain');
echo http_build_query($reply, '', '&');
?>



_________________
Samuel
ChatBlazer Support
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron