ajax_chat [message #2111] |
Mon, 09 June 2008 06:24  |
|
MOD-Tittle:Ajax chat
MOD-Version:Beta 1.0.0 beta
MOD-Setup Time:Under 5 minutes
MOD-description:
Ajax Chat for PMBT adds Ajax shoutbox to your site witch well remove the need for constant refreshing of the index(or any other page)for your shoutbox.
You dont need to login for it to work it well automatically set user name and rank.
The only access is for members.
MOD-install:
- Extracket content and upload to your root directory
- Extracket content and upload to your root directory
- open lib/config.php
| Quote: | // Database hostname:
$config['dbConnection']['host'] = 'localhost';
// Database username:
$config['dbConnection']['user'] = "";
// Database password:
$config['dbConnection']['pass'] = "";
// Database name:
$config['dbConnection']['name'] = "";
|
and save.
- Go to yoursite.net/chat/install.php
- now remove /chat/install.php
- open themes/yourtheme/styles.css
and add to top@import url("http://www.yoursite.net/chat/css/shoutbox.css");
this must be the first line
- now open include/functions and add
<?php
function getShoutBoxContent() {
global $user, $db, $db_prefix, $localhost_autologin;
@setcookie('PMBTNAME',$user->name,time()+1200,$cookiepath,$cookiedomain,0);
@setcookie('PMBT_USERID',$user->id,time()+1200,$cookiepath,$cookiedomain,0);
if($user->user)@setcookie('ACTIVE_USER','true',time()+1200,$cookiepath,$cookiedomain,0);
else
@setcookie('ACTIVE_USER','false',time()+1200,$cookiepath,$cookiedomain,0);
if($user->admin)@setcookie('PMBT_ADMIN','true',time()+1200,$cookiepath,$cookiedomain,0);
else
@setcookie('PMBT_ADMIN','false',time()+1200,$cookiepath,$cookiedomain,0);
if($user->moderator)@setcookie('PMBT_MOD','true',time()+1200,$cookiepath,$cookiedomain,0);
else
@setcookie('PMBT_MOD','false',time()+1200,$cookiepath,$cookiedomain,0);
// URL to the chat directory:
if(!defined('AJAX_CHAT_URL')) {
define('AJAX_CHAT_URL', '/chat/');
}
// Path to the chat directory:
if(!defined('AJAX_CHAT_PATH')) {
define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/chat').'/');
}
// Validate the path to the chat:
if(@is_file(AJAX_CHAT_PATH.'lib/classes.php')) {
// Include Class libraries:
require_once(AJAX_CHAT_PATH.'lib/classes.php');
// Initialize the shoutbox:
$ajaxChat = new CustomAJAXChatShoutBox();
// Parse and return the shoutbox template content:
return $ajaxChat->getShoutBoxContent();
}
return null;
}
?>
- Now open header.php and find
include("blocks/shoutbox.php"); and remove or comment it out
- now we decide where we want new shout if you want it in same place then add
if ($user->user)
{
OpenTable('testajax');
echo getShoutBoxContent();
CloseTable();
}
at same location
if you want to add it to top of each page then add it right before the ?>
if you only want it in the index then open index.php and add it bellow if ($welcome_message != ""){
OpenTable(_btsitenews);
echo "<table><tr><td>$welcome_message</td></tr></table>";
CloseTable();
}
and thats it your done
[Updated on: Sat, 14 June 2008 13:45] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|