It is currently Sun Apr 30, 2017 12:49 pm




 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: Integration with phpFox
PostPosted: Tue Sep 14, 2010 3:38 am 
Support Staff

Joined: Fri Nov 01, 2002 4:06 am
Posts: 43
This topic contains instructions for chat hosting customers to integrate with phpFox V2. Server license customers should be able to adapt some portions which are relevant only to chat hosting customers.

1. Create a page under CMS | Pages | Add New Page.

2. For Page Data, include the following code given by the client code generator, e.g. only the part within the <script> tags. Don't forget to specify your account's Site ID.

<?php
$u = Phpfox::getUserBy('user_name');
// getUserBy password not working so retrieve the entire user record
$user = Phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('user'))->where('user_id = ' . Phpfox::getUserId())->execute('getRow');
if ($user) {
   $p = base64_encode($user['password']);
}
if ($u && $p) {
   echo <<<BODY
<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>

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

   // username and password used for direct login only
   var session = "";
   var directUsername = "$u";
   var directPassword = "$p";
   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
   var textColor      = "";   // #FFFFFF

   // import user profile settings, bypassing config.xml's profile import settings
   var profileAvatar   = ""; // path to avatar image
   var profileReal      = "";
   var profileGender   = "";
   var profileAge      = "";
   var profileEmail   = "";
   var profileDOB      = "";
   var profileCountry   = "";
   var profileAlias   = "";

   // retrieve user profile via Forum/CMS, e.g. phpBB, vBulletin
   // e.g. /phpBB3/cbuserinfo.php?username={username}
   //      where {username} is the username
   //var profileScript   = "http://192.168.1.40/phpBB3/cbuserinfo.php?username={username}";
   var profileScript   = "";

   // Size of ChatBlazer application in % or pixels
   var chatWidth      = "965px";
   var chatHeight      = "550px";

   // path of chat
   var flashPath = "ChatBlazer8"+(mainSkin?"_"+mainSkin:"")+".swf?cb=1";
   var flashVersion = "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("session",session);
   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);

   addParam("profilescript",profileScript);

   addParam("profileavatar",profileAvatar);
   addParam("profilereal",profileReal);
   addParam("profilegender",profileGender);
   addParam("profileage",profileAge);
   addParam("profileemail",profileEmail);
   addParam("profiledob",profileDOB);
   addParam("profilecountry",profileCountry);
   addParam("profilealias",profileAlias);

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

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

//-->
</script>
BODY;
}
else {
   echo <<<BODY
Please log in to use the chat rooms.
BODY;
}
?>

For the Parser field, uncheck BBCode, Emoticons and Add Smart Breaks. Only PHP should be checked.

3. Create a menu for the chat page you created in step 2, e.g. "Chat Rooms", under CMS | Menus | Add New Menu.

4. Create a PHP script with the following content. This script will be called by the ChatBlazer server for authentication. Substitute the location of your phpFox installation, i.e. PHPFOX_DIR. You can add the script under PHPFOX_DIR/module/chatblazer/phpfox_auth.php.

<?php
define('PHPFOX', TRUE);
define('PHPFOX_DS', DIRECTORY_SEPARATOR);
define('PHPFOX_DIR', '/home/myuser/public_html' . PHPFOX_DS);
define('PHPFOX_START_TIME', array_sum(explode(' ', microtime())));

// Require phpFox Init
require(PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php');

// Only accept HTTP POST
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
   exit;
}

$name = $_POST['username'];
$password = base64_decode($_POST['password']);

$reply = NULL;
$user = Phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('user'))->where("user_name = '$name'")->execute('getRow');
if (is_array($user) && count($user) > 0) {
   // check password
   if (strcmp($user['password'], $password) == 0) {
      $reply = array('username' => $user['user_name']);
   }
}

if ($reply) {
   header('Content-Type: text/plain');
   echo http_build_query($reply);
}
?>


5. Specify the script's URL in the chat admin, under Site Settings | External User Data Source. e.g. http://www.mywebsite.com/module/chatbla ... x_auth.php


That's it! Now your registered users in phpFox will automatically log into the chat client when they access the chat page.


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