MyBB Community Forums

Full Version: how to add a mod
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how do you add a mod ?

i downloaded a free chat thing (is that a chatbox) and i dont know how to add it. I have got my site on createmybb2.com
The best way is to read instructions from author.
i have read it but i cant find what he looking for

Quote:<?php
/**
* phpFreeChat Plugin for MyBB
* Copyright © 2006 MyBB Mods
* URL: http://mods.mybboard.com/
*
* By: Ichibod, Silve
* With contributions from:
* ernolf - many tweaks and German tranlation
* & many others. Thanks all!
*
* Based on Plugins by: Musicalmidget
* Website: http://www.musicalmidget.com/
*/

/* GLOBALS */
global $pfc_mybb_obj, $pfc_mybb__ok_to_disp;

$plugins->add_hook('global_start', 'pfc_mybb_chat');
//$plugins->add_hook('index_start', 'pfc_mybb_chat'); // NOTE: NOT needed as this hook is not needed as it is a subset of 'global_start'.

/* common hooks */
// used for inserting javascript into the header
$plugins->add_hook("pre_output_page", "pfc_mybb_header");


// Function to setup phpFreeChat plugin into MyBB.
//
// @ (none)
function pfc_mybb_info()
{
return array(
'name' => "Embed phpFreeChat into MyBB",
'description' => "Integrates phpFreeChat into MyBB",
'website' => "http://mods.mybboard.com/",
'author' => "Ichibod, Silve",
'authorsite' => "http://mods.mybboard.com/",
'version' => "1.9-betaAngel",
);
}

// Function to enable phpFreeChat plugin.
//
// @ (none)
function pfc_mybb_activate()
{
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
global $db, $lang;

// Load language phrases
$language = $mybb->settings['bblanguage'];
if(!$lang->language_exists($language."/admin/php_mybb.lang"))
{
$lang->set_language("english", "admin");
}
$lang->load("pfc_mybb");
$lang->set_language($mybb->settings['bblanguage']);

$pfc_mybb_group = array(
'name' => 'pfc_mybb',
'title' => $lang->pfc_mybb__lang__title,
'description' => $lang->pfc_mybb__lang__desc,
'disporder' => 200,
'isdefault' => 'off',
);

$db->insert_query(TABLE_PREFIX.'settinggroups', $pfc_mybb_group);
$gid = $db->insert_id();

// Tier 1 Options
$pfc_mybb_setting_1 = array(
'name' => 'show_pfc_mybb',
'title' => $lang->show_pfc_mybb__lang__title,
'description' => $lang->show_pfc_mybb__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 1,
'gid' => intval($gid),
);
/* -- not working quite yet ---
$pfc_mybb_setting_2 = array(
'name' => 'pfc_mybb__flush_caches',
'title' => $lang->pfc_mybb__flush_caches__lang__title,
'description' => $db->escape_string($lang->pfc_mybb__flush_caches__lang__desc),
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 2,
'gid' => intval($gid),
);
*/
$pfc_mybb_setting_3 = array(
'name' => 'pfc_mybb__vers1_9_beta_plus',
'title' => $lang->pfc_mybb__vers1_9_beta_plus__lang__title,
'description' => $lang->pfc_mybb__vers1_9_beta_plus__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 3,
'gid' => intval($gid),
);
$pfc_mybb_setting_4 = array(
'name' => 'pfc_mybb__pfc_path',
'title' => $lang->pfc_mybb__pfc_path__lang__title,
'description' => $lang->pfc_mybb__pfc_path__lang__desc,
'optionscode' => 'text',
'value' => '/var/www/chat',
'disporder' => 4,
'gid' => intval($gid),
);
$pfc_mybb_setting_5 = array(
'name' => 'pfc_mybb__position',
'title' => $lang->pfc_mybb__position__lang__title,
'description' => $lang->pfc_mybb__position__lang__desc,
'optionscode' => $db->escape_string(sprintf($lang->pfc_mybb__position__lang__options, 'toplink', 'header', 'index')),
'value' => 'toplink',
'disporder' => 5,
'gid' => intval($gid),
);
$pfc_mybb_setting_6 = array(
'name' => 'pfc_mybb__start_minimized',
'title' => $lang->pfc_mybb__start_minimized__lang__title,
'description' => $lang->pfc_mybb__start_minimized__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 6,
'gid' => intval($gid),
);
$pfc_mybb_setting_7 = array(
'name' => 'pfc_mybb__theme',
'title' => $lang->pfc_mybb__theme__lang__title,
'description' => $lang->pfc_mybb__theme__lang__desc,
'optionscode' => 'text',
'value' => 'default',
'disporder' => 7,
'gid' => intval($gid),
);
$pfc_mybb_setting_8 = array(
'name' => 'pfc_mybb__user_ctrl_chat',
'title' => $lang->pfc_mybb__user_ctrl_chat__lang__title,
'description' => $db->escape_string($lang->pfc_mybb__user_ctrl_chat__lang__desc),
'optionscode' => 'text',
'value' => '0',
'disporder' => 8,
'gid' => intval($gid),
);
$pfc_mybb_setting_9 = array(
'name' => 'pfc_mybb__server_id_field',
'title' => $lang->pfc_mybb__server_id_field__lang__title,
'description' => $lang->pfc_mybb__server_id_field__lang__desc,
'optionscode' => 'text',
'value' => 'mybb_pfc1.9-betaAngel',
'disporder' => 9,
'gid' => intval($gid),
);

// Tier 2 Options
$pfc_mybb_setting_25 = array(
'name' => 'pfc_mybb__title',
'title' => $lang->pfc_mybb__title__lang__title,
'description' => $lang->pfc_mybb__title__lang__desc,
'optionscode' => 'text',
'value' => $lang->pfc_mybb__title__lang__value,
'disporder' => 25,
'gid' => intval($gid),
);
$pfc_mybb_setting_26 = array(
'name' => 'pfc_mybb__channel',
'title' => $lang->pfc_mybb__channel__lang__title,
'description' => $lang->pfc_mybb__channel__lang__desc,
'optionscode' => 'text',
'value' => $lang->pfc_mybb__channel__lang__value,
'disporder' => 26,
'gid' => intval($gid),
);
$pfc_mybb_setting_27 = array(
'name' => 'pfc_mybb__height',
'title' => $lang->pfc_mybb__height__lang__title,
'description' => $lang->pfc_mybb__height__lang__desc,
'optionscode' => 'text',
'value' => '200',
'disporder' => 27,
'gid' => intval($gid),
);
$pfc_mybb_setting_28 = array(
'name' => 'pfc_mybb__width',
'title' => $lang->pfc_mybb__width__lang__title,
'description' => $lang->pfc_mybb__width__lang__desc,
'optionscode' => 'text',
'value' => '800',
'disporder' => 28,
'gid' => intval($gid),
);
$pfc_mybb_setting_29 = array(
'name' => 'pfc_mybb__max_channels',
'title' => $lang->pfc_mybb__max_channels__lang__title,
'description' => $lang->pfc_mybb__max_channels__lang__desc,
'optionscode' => 'text',
'value' => '10',
'disporder' => 29,
'gid' => intval($gid),
);
$pfc_mybb_setting_30 = array(
'name' => 'pfc_mybb__max_privmsg',
'title' => $lang->pfc_mybb__max_privmsg__lang__title,
'description' => $lang->pfc_mybb__max_privmsg__lang__desc,
'optionscode' => 'text',
'value' => '5',
'disporder' => 30,
'gid' => intval($gid),
);
$pfc_mybb_setting_31 = array(
'name' => 'pfc_mybb__refresh_delay',
'title' => $lang->pfc_mybb__refresh_delay__lang__title,
'description' => $lang->pfc_mybb__refresh_delay__lang__desc,
'optionscode' => 'text',
'value' => '5000',
'disporder' => 31,
'gid' => intval($gid),
);
$pfc_mybb_setting_32 = array(
'name' => 'pfc_mybb__max_refresh_delay',
'title' => $lang->pfc_mybb__max_refresh_delay__lang__title,
'description' => $lang->pfc_mybb__max_refresh_delay__lang__desc,
'optionscode' => 'text',
'value' => '60000',
'disporder' => 32,
'gid' => intval($gid),
);
$pfc_mybb_setting_33 = array(
'name' => 'pfc_mybb__timeout',
'title' => $lang->pfc_mybb__timeout__lang__title,
'description' => $lang->pfc_mybb__timeout__lang__desc,
'optionscode' => 'text',
'value' => '20000',
'disporder' => 33,
'gid' => intval($gid),
);
$pfc_mybb_setting_34 = array(
'name' => 'pfc_mybb__max_msg',
'title' => $lang->pfc_mybb__max_msg__lang__title,
'description' => $lang->pfc_mybb__max_msg__lang__desc,
'optionscode' => 'text',
'value' => '20',
'disporder' => 34,
'gid' => intval($gid),
);
$pfc_mybb_setting_35 = array(
'name' => 'pfc_mybb__max_displayed_lines',
'title' => $lang->pfc_mybb__max_displayed_lines__lang__title,
'description' => $lang->pfc_mybb__max_displayed_lines__lang__desc,
'optionscode' => 'text',
'value' => '150',
'disporder' => 35,
'gid' => intval($gid),
);
$pfc_mybb_setting_36 = array(
'name' => 'pfc_mybb__allow_guests',
'title' => $lang->pfc_mybb__allow_guests__lang__title,
'description' => $lang->pfc_mybb__allow_guests__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 36,
'gid' => intval($gid),
);
$pfc_mybb_setting_37 = array(
'name' => 'pfc_mybb__allow_nonactives',
'title' => $lang->pfc_mybb__allow_nonactives__lang__title,
'description' => $lang->pfc_mybb__allow_nonactives__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 37,
'gid' => intval($gid),
);
$pfc_mybb_setting_38 = array(
'name' => 'pfc_mybb__allow_customs',
'title' => $lang->pfc_mybb__allow_customs__lang__title,
'description' => $lang->pfc_mybb__allow_customs__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 38,
'gid' => intval($gid),
);

// Tier 3 Options
$pfc_mybb_setting_50 = array(
'name' => 'pfc_mybb__show_notice',
'title' => $lang->pfc_mybb__show_notice__lang__title,
'description' => $lang->pfc_mybb__show_notice__lang__desc,
'optionscode' => 'text',
'value' => '0',
'disporder' => 50,
'gid' => intval($gid),
);
$pfc_mybb_setting_51 = array(
'name' => 'pfc_mybb__nickmarker',
'title' => $lang->pfc_mybb__nickmarker__lang__title,
'description' => $lang->pfc_mybb__nickmarker__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 51,
'gid' => intval($gid),
);
$pfc_mybb_setting_52 = array(
'name' => 'pfc_mybb__clock',
'title' => $lang->pfc_mybb__clock__lang__title,
'description' => $lang->pfc_mybb__clock__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 52,
'gid' => intval($gid),
);
$pfc_mybb_setting_53 = array(
'name' => 'pfc_mybb__startwithsound',
'title' => $lang->pfc_mybb__startwithsound__lang__title,
'description' => $lang->pfc_mybb__startwithsound__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 53,
'gid' => intval($gid),
);
$pfc_mybb_setting_54 = array(
'name' => 'pfc_mybb__showwhosonline',
'title' => $lang->pfc_mybb__showwhosonline__lang__title,
'description' => $lang->pfc_mybb__showwhosonline__lang__desc,
'optionscode' => 'onoff',
'value' => 'on',
'disporder' => 54,
'gid' => intval($gid),
);
$pfc_mybb_setting_55 = array(
'name' => 'pfc_mybb__showsmileys',
'title' => $lang->pfc_mybb__showsmileys__lang__title,
'description' => $lang->pfc_mybb__showsmileys__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 55,
'gid' => intval($gid),
);
$pfc_mybb_setting_56 = array(
'name' => 'pfc_mybb__btn_sh_whosonline',
'title' => $lang->pfc_mybb__btn_sh_whosonline__lang__title,
'description' => $lang->pfc_mybb__btn_sh_whosonline__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 56,
'gid' => intval($gid),
);
$pfc_mybb_setting_57 = array(
'name' => 'pfc_mybb__btn_sh_smileys',
'title' => $lang->pfc_mybb__btn_sh_smileys__lang__title,
'description' => $lang->pfc_mybb__btn_sh_smileys__lang__desc,
'optionscode' => 'onoff',
'value' => 'off',
'disporder' => 57,
'gid' => intval($gid),
);


// Tier 1
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_1);
/*
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_2);
*/
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_3);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_4);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_5);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_6);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_7);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_8);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_9);

// Tier 2
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_25);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_26);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_27);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_28);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_29);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_30);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_31);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_32);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_33);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_34);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_35);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_36);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_37);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_38);

// Tier 3
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_50);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_51);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_52);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_53);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_54);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_55);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_56);
$db->insert_query(TABLE_PREFIX.'settings', $pfc_mybb_setting_57);

$pfc_mybb_embed_template = array(
"title" => 'global_pfc_mybb',
"template" => "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">
<tbody>
<tr>
<td class=\"trow1\"><!-- pfc_mybb start -->\$pfc_mybb_obj__chat_window<!-- pfc_mybb stop --></td>
</tr>
</tbody>
</table>
<br />",
"sid" => -1,
"version" => 123,
"status" => '',
"dateline" => 1156555642,
);
$db->insert_query(TABLE_PREFIX.'templates', $pfc_mybb_embed_template);

// <!---- Put ALL potential references into the plugin! ---->
/***************************** embed in header *****************************/
// used to embed in the header
find_replace_templatesets('header', '#<navigation>#', "{\$pfc_mybb_obj__header}\n\t\t\t<navigation>");

/***************************** embed in index *****************************/
// used to embed in the index
find_replace_templatesets("index", '#{\$forums}(\r?)\n#', "{\$pfc_mybb_obj__index}\n{\$forums}\n");

/***************************** embed in toplink, new popup window *****************************/
// Add the downloads section link to the forum header
//find_replace_templatesets("header", '#toplinks_help}</a></li>#', "toplinks_help}</a></li>\n<li><a href=\"{\$mybb->settings['bburl']}/pfc_mybb_popup.php\" onClick=\"return popup(this, 'notes')\"><img src=\"{\$theme['imgdir']}/toplinks/chat_icon.gif\" border=\"0\" alt=\"{\$lang->pfc_mybb__lang_toplink}\" />{\$lang->pfc_mybb__lang_toplink}</a></li>");
find_replace_templatesets("header", '#toplinks_help}</a></li>#', "toplinks_help}</a></li>\n{\$pfc_mybb__toplink_code}");
}

// Function disable phpFreeChat plugin.
//
// @ (none)
function pfc_mybb_deactivate()
{
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
global $db, $mybb;

// Tier 1 Options
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('show_pfc_mybb', 'pfc_mybb')");
/*
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__flush_caches', 'pfc_mybb')");
*/
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__vers1_9_beta_plus', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__pfc_path', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__position', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__start_minimized', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__theme', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__user_ctrl_chat', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__server_id_field', 'pfc_mybb')");

// Tier 2 Options
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__title', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__channel', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__height', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__width', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__max_channels', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__max_privmsg', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__refresh_delay', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__max_refresh_delay', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__timeout', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__max_msg', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__max_displayed_lines', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__allow_guests', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__allow_nonactives', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__allow_customs', 'pfc_mybb')");

// Tier 3 Options
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__show_notice', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__startwithsound', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__nickmarker', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__clock', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__showwhosonline', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__showsmileys', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__btn_sh_whosonline', 'pfc_mybb')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('pfc_mybb__btn_sh_smileys', 'pfc_mybb')");


$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='pfc_mybb'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='global_pfc_mybb'");

// <!---- remove ALL potential references to the plugin! ---->
/***************************** un-embed in header *****************************/
find_replace_templatesets('header', '#{\$pfc_mybb_obj__header}\n\t\t\t#', '', 0);
/***************************** un-embed in index *****************************/
find_replace_templatesets("index", '#{\$pfc_mybb_obj__index}(\r?)\n#', "", 0);
/***************************** un-embed in toplink, new popup window *****************************/
//find_replace_templatesets("header", '#\n<li><a href="{\$mybb->settings\[\'bburl\'\]}/pfc_mybb_popup.php" onClick="return popup\(this, \'notes\'\)"><img src="{\$theme\[\'imgdir\'\]}/toplinks/chat_icon.gif" border="0" alt="{\$lang->pfc_mybb__lang_toplink}" />{\$lang->pfc_mybb__lang_toplink}</a></li>#', '', 0);
find_replace_templatesets("header", '#\n{\$pfc_mybb__toplink_code}#', '', 0);
}


// Function to display a phpFreeChat into MyBB.
//
// @ (none)
function pfc_mybb_chat()
{
global $mybb, $templates, $lang, $pfc_mybb_obj, $pfc_mybb_obj__chat_window, $pfc_mybb_obj__header, $pfc_mybb_obj__index, $pfc_mybb__ok_to_disp, $pfc_mybb__toplink_code;

// print the chat room includes
require_once($mybb->settings['pfc_mybb__pfc_path']."/src/phpfreechat.class.php");

// Load language phrases
$language = $mybb->settings['bblanguage'];
if(!$lang->language_exists($language."/pfc_mybb.lang"))
{
$lang->set_language("english");
}
$lang->load("pfc_mybb");

// initialize variables
$pfc_mybb__ok_to_disp = false;

// see if current user can AND WANTS to use this; start by checking user's profile
if ($mybb->settings['show_pfc_mybb'] == 'on')
{
$user_enabled_chat = true;
if (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 0) // user has control
{
if (stristr($mybb->user["notepad"], 'chat=off') || stristr($mybb->user["notepad"], 'chat=no'))
{
$user_enabled_chat = false;
}
}

// then run standard usergroup setup =
// 1: Unregistered / Not logged in. -- ask
// 2: Registered -- ok
// 3: Supermod -- ok
// 4: Admin -- ok
// 5: Non-Activated -- ask
// 6: Moderator -- ok
// 7: Banned -- block this one for sure
// 8+: customs? -- ask
if ( $user_enabled_chat &&
(
(($mybb->user['usergroup'] <= 1) && ($mybb->settings['pfc_mybb__allow_guests'] == 'on')) || // 1: Unregistered / Not logged in. -- ask
(($mybb->user['usergroup'] >= 2) && ($mybb->user['usergroup'] <= 4)) || // 2: Registered, 3: Supermod, 4: Admin -- ok
(($mybb->user['usergroup'] == 5) && ($mybb->settings['pfc_mybb__allow_nonactives'] == 'on')) || // 5: Non-Activated -- ask
(($mybb->user['usergroup'] == 6)) || // 6: Moderator -- ok, 7: Banned -- block this one for sure
(($mybb->user['usergroup'] >= 8) && ($mybb->settings['pfc_mybb__allow_customs'] == 'on')) // 8+: customs? -- ask
)
)
{
// set $pfc_mybb__ok_to_disp to true
$pfc_mybb__ok_to_disp = true;

// at this point it's ok to draw the toplink if that's how the chat is integrated
if ( ( (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) < 2) && ($mybb->settings['pfc_mybb__position'] == 'toplink') ) || // user has no control and Admin wants toplink
( (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 1) && (stristr($mybb->user["notepad"], 'chat=toplink')) ) || // user has control and wants toplink
( (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 1) && (stristr($mybb->user["notepad"], 'chat=header') == false) &&
(stristr($mybb->user["notepad"], 'chat=index') == false) && ($mybb->settings['pfc_mybb__position'] == 'toplink')
) // user has control, but has set no pref, and Admin wants toplink
)
{
// scale the window to be 10px x 200px larger than the chat window itself
$pfc_mybb__popup_window_width = (intval($mybb->settings['pfc_mybb__width']) + 10);
$pfc_mybb__popup_window_height = (intval($mybb->settings['pfc_mybb__height']) + 200);
/* This one uses the MyBB's built-in javascript goodies */
$pfc_mybb__toplink_code = "\n<li><a href=\\\"#\\\" onclick=\\\"MyBB.popupWindow('{\$mybb->settings['bburl']}/pfc_mybb_popup.php', 'pfc_mybb__popup_window', {\$pfc_mybb__popup_window_width}, {\$pfc_mybb__popup_window_height});\\\"><img src=\\\"{\$mybb->settings['bburl']}/images/toplinks/chat_icon.gif\\\" border=\\\"0\\\" alt=\\\"|{\$lang->pfc_mybb__lang_toplink}|\\\" align=absmiddle />{\$lang->pfc_mybb__lang_toplink}</a></li>";

/* This one uses the custom javascript defined in pfc_mybb_header() function below -- no need to use unless MyBB built-ins stop working as we expect. */
//$pfc_mybb__toplink_code = "\n<li><a href=\\\"{\$mybb->settings['bburl']}/pfc_mybb_popup.php\\\" onClick=\\\"return popup(this, 'pfc_mybb__popup_window')\\\"><img src=\\\"{\$mybb->settings['bburl']}/images/toplinks/chat_icon.gif\\\" border=\\\"0\\\" alt=\\\"|{\$lang->pfc_mybb__lang_toplink}|\\\" />{\$lang->pfc_mybb__lang_toplink}</a></li>";

eval("\$pfc_mybb__toplink_code = \"$pfc_mybb__toplink_code\";");
}

// ok to display; see if a new pfc_chat needs setup; if not, create one!
if ( !isset($pfc_mybb_obj) )
{
// setup parameter array
$params = array();

//$params["debug"] = true;

if ($mybb->user['usergroup'] > 1) // user is not a guest
{
$params["nick"] = "".$mybb->user['username']; // setup nickname to match username
}
/* // this does not appear to be working properly Sad No cookies to guests causing it?
else
{
$params["nick"] = "guest".rand(1,10000); // randomly create a nick for the guest
}
*/
if ( ($mybb->user['usergroup'] == 3) || // 3: Supermod -- ok
($mybb->user['usergroup'] == 4) || // 4: Admin -- ok
($mybb->user['usergroup'] == 6) // 6: Moderator -- ok
)
{
$params["isadmin"] = true; // set admin privs
}
else
{
$params["isadmin"] = false; // NO admin privs
}
$params["title"] = "".$mybb->settings['pfc_mybb__title'];

//$params["channels"] = array($mybb->settings['pfc_mybb__channel']); // set default channel
$chan_list = explode(',', $mybb->settings['pfc_mybb__channel']);
if ($chan_list != null)
{
$params["channels"] = $chan_list; // set default channel(s)
}
else
{
$params["channels"] = array("Default"); // set to default
}

//$params["frozen_channels"] = ""; // allows users to create own channels
$params["max_channels"] = intval($mybb->settings['pfc_mybb__max_channels']); // limit the number of joined channels tab to 10
//$params["privmsg"] = array(); // the joined private chat when opening the chat (the nicknames must be online)
$params["max_privmsg"] = intval($mybb->settings['pfc_mybb__max_privmsg']); // limit the number of private message tab to 5
$params["frozen_nick"] = true; // do not allow to change the nickname
$params["max_nick_len"] = 20; // nickname length could not be longer than 10 characteres
$params["max_text_len"] = 300; // a message cannot be longer than 300 characteres
$params["refresh_delay"] = intval($mybb->settings['pfc_mybb__refresh_delay']); // chat refresh speed (default is 5 seconds (5000ms))
$params["max_refresh_delay"] = intval($mybb->settings['pfc_mybb__max_refresh_delay']); // in mili-seconds (default is 60 seconds (60000ms))
$params["timeout"] = intval($mybb->settings['pfc_mybb__timeout']); // in mili-seconds (20 seconds)
$params["max_msg"] = intval($mybb->settings['pfc_mybb__max_msg']); // number of messages keept in the history (this is what you see when you reload the chat)
$params["max_displayed_lines"] = intval($mybb->settings['pfc_mybb__max_displayed_lines']); // maximum number of displayed lines (old lines will be deleted to save browser's memory)
if ($mybb->settings['pfc_mybb__position'] == 'toplink') // check for focus on connect
{
// we're in a popup, so go ahead and grab focus
$params["focus_on_connect"] = true;
}
else
{
// we're embedded. Do NOT focus! Enabling this will cause your BB to shift to the location of the chat window - annoying
$params["focus_on_connect"] = false;
}
$params["connect_at_startup"] = true; // connect at startup
if ($mybb->settings['pfc_mybb__start_minimized'] == 'on') // start the chat box minimized
{
$params["start_minimized"] = true;
}
else
{
$params["start_minimized"] = false;
}
$params["height"] = "".$mybb->settings['pfc_mybb__height']."px"; // height of chat area is 220px (default is 440)
$params["width"] = "".$mybb->settings['pfc_mybb__width']."px"; // width of chat area (default is 800px)

$show_notice_val = intval($mybb->settings['pfc_mybb__show_notice']);
if ( ($show_notice_val >= 0) && ($show_notice_val <= 3) )
{
$params["shownotice"] = $show_notice_val; // 0 = nothing, 1 = just nickname changes, 2 = connect/quit, 3 = nick + connect/quit
}
else
{
$params["shownotice"] = 0;
}
if ($mybb->settings['pfc_mybb__nickmarker'] == 'on')
{
$params["nickmarker"] = true;
}
else
{
$params["nickmarker"] = false;
}
if ($mybb->settings['pfc_mybb__clock'] == 'on')
{
$params["clock"] = true;
}
else
{
$params["clock"] = false;
}
if ($mybb->settings['pfc_mybb__startwithsound'] == 'on') // start with sound enabled
{
$params["startwithsound"] = true;
}
else
{
$params["startwithsound"] = false;
}
if ($mybb->settings['pfc_mybb__showwhosonline'] == 'on')
{
$params["showwhosonline"] = true;
}
else
{
$params["showwhosonline"] = false;
}
if ($mybb->settings['pfc_mybb__showsmileys'] == 'on')
{
$params["showsmileys"] = true;
}
else
{
$params["showsmileys"] = false;
}
if ($mybb->settings['pfc_mybb__btn_sh_whosonline'] == 'on')
{
$params["btn_sh_whosonline"] = true;
}
else
{
$params["btn_sh_whosonline"] = false;
}
if ($mybb->settings['pfc_mybb__btn_sh_smileys'] == 'on')
{
$params["btn_sh_smileys"] = true;
}
else
{
$params["btn_sh_smileys"] = false;
}

$params["theme"] = "".$mybb->settings['pfc_mybb__theme']; // this can be altered, but themes appear to slow processing
//$params["data_private_path"] = "/dev/shm/pfcdata/private";
//$params["data_public_path"] = "/dev/shm/pfcdata/public";

// non-pfcglobalconfig.class.php options
if ($mybb->settings['pfc_mybb__server_id_field'] != "")
{
$params["serverid"] = "".$mybb->settings['pfc_mybb__server_id_field']; // use admin-selected server id
}
else
{
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
}

// create chat session
$pfc_mybb_obj = new phpFreeChat($params);
}

// ok to display, double-check existence (previous should have created it if not already present)
if ( isset($pfc_mybb_obj) )
{
//printChat() will create the window
$pfc_mybb_obj__chat_window = $pfc_mybb_obj->printChat("true");
}
else
{
$pfc_mybb_obj__chat_window = $lang->pfc_mybb__lang_chat_window__init_fail;
}
}
else // not usable by this user
{
if (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 0)
{
if (stristr($mybb->user["notepad"], 'chat=off') || stristr($mybb->user["notepad"], 'chat=no'))
{
$pfc_mybb_obj__chat_window = $lang->pfc_mybb__lang_chat_window__disabled;
}
else
{
$pfc_mybb_obj__chat_window = $lang->pfc_mybb__lang_chat_window__invalid_perms;
}
}
else
{
$pfc_mybb_obj__chat_window = $lang->pfc_mybb__lang_chat_window__invalid_perms;
}
}

// see if user can specify chat location (0=no, 1=on/off ONLY, 2=on/off + location)
$pfc_mybb__user_set = false;
if (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 1)
{
$pfc_mybb__user_set = true;
if (stristr($mybb->user["notepad"], 'chat=toplink'))
{
// popup just needs to print out the $pfc_mybb_obj__chat_window
}
elseif (stristr($mybb->user["notepad"], 'chat=header'))
{
// chat shows in the header
eval("\$pfc_mybb_obj__header = \"".$templates->get('global_pfc_mybb')."\";");
}
elseif (stristr($mybb->user["notepad"], 'chat=index'))
{
// chat shows in the index
eval("\$pfc_mybb_obj__index = \"".$templates->get('global_pfc_mybb')."\";");
}
else // no dice, let the Admin's default do it.
{
$pfc_mybb__user_set = false;
}
}

if ($pfc_mybb__user_set == false) // user can't set or failed to set
{
// evaluate the whole thing based on AdminPreference
switch($mybb->settings['pfc_mybb__position'])
{
case('toplink'):
{
// popup just needs to print out the $pfc_mybb_obj__chat_window
break;
}
case('header'):
{
// chat shows in the header
eval("\$pfc_mybb_obj__header = \"".$templates->get('global_pfc_mybb')."\";");
break;
}
case('index'):
{
// chat shows in the index
eval("\$pfc_mybb_obj__index = \"".$templates->get('global_pfc_mybb')."\";");
break;
}
default:
{
// clear all the variables -- chat shows nowhere
$pfc_mybb_obj__chat_window="";
$pfc_mybb_obj__header = "";
$pfc_mybb_obj__index = "";
break;
}
}
}
}
}

// Function to append various javascripts and older phpFreeChat style info into mybb headers.
//
// @ returns $page ... modified with extra goodies in the <head> section of course
function pfc_mybb_header($page)
{
global $mybb, $pfc_mybb_obj, $pfc_mybb__ok_to_disp;

/* --- Any additional javascripts need loaded? Set to 'true' if so. --- */
$additional_js = false;

if ( $added_js || ($mybb->settings['pfc_mybb__vers1_9_beta_plus'] == 'off') )
{
// split the page into "header section" (page_parts[0]) & "everything else" (page_parts[1])
$page_parts = explode("<head>", $page, 2);
// plop the <head> tag back into the page source (previous exlode() call removed it)
$page_parts[0] = $page_parts[0]." <head>";

/* Additional javascripts for ALL pages */
/*
// toplink enabled? if so, add generic popup support to the page. <= old way of doing it w/o using MyBB constructs.
if ($mybb->settings['pfc_mybb__position'] == 'toplink')
{
$pfc_mybb_headerjs = "
<!-- START: pfc_mybb_plugin custom javascripts -->
<script type=\\\"text/javascript\\\">
<!--
function popup(the_link, the_windowname)
{
if (! window.focus)return true;
var href;
if (typeof(the_link) == 'string')
href=the_link;
else
href=the_link.href;
window.open(href, the_windowname, 'width={\$mybb->settings['pfc_mybb__width']},height={\$mybb->settings['pfc_mybb__height']},scrollbars=no,resizable=yes,dependent=yes,location=no');
return false;
}
//-->
</script>
<!-- END: pfc_mybb_plugin custom javascripts -->
";
// lock in the php in $pfc_mybb_headerjs
eval("\$pfc_mybb_headerjs = \"$pfc_mybb_headerjs\";");
// Include extra javascripts
$page_parts[0] = $page_parts[0].$pfc_mybb_headerjs;
}
*/
/* Additional javascripts for phpFreeChat versions < 1.9-beta */
// As of PFC 1.9-beta, these calls are no longer required! Here for phpFreeChat older than 1.9-beta support
if ($mybb->settings['show_pfc_mybb'] == 'on')
{
// verify user wants to display
$user_enabled_chat = true;
if (intval($mybb->settings['pfc_mybb__user_ctrl_chat']) > 0)
{
if (stristr($mybb->user["notepad"], 'chat=off') || stristr($mybb->user["notepad"], 'chat=no'))
{
$user_enabled_chat = false;
}
}
if ( ($mybb->settings['pfc_mybb__vers1_9_beta_plus'] == 'off') && $user_enabled_chat && isset($pfc_mybb_obj) && ($pfc_mybb__ok_to_disp == true) )
{
// Include our chat javascripts
$page_parts[0] = $page_parts[0].$pfc_mybb_obj->printJavascript("true");
// Include our stylesheets
$page_parts[0] = $page_parts[0].$pfc_mybb_obj->printStyle("true");
}
}

/********* Sew it all back together *********/
// reassemble the full page
$page = $page_parts[0].$page_parts[1];
// pass the page back to output_page() to display the page
return $page;
}
}

/* CODE to DUMP phpFreeChat's CACHE
* Taken from: http://www.phpfreechat.net/forum/viewtopic.php?pid=4158
* phpFreeChat's website
*
* // To use this, you must set correct permissions on folder data folders to 777.
*
* // how to call this:
* if (@opendir('data/public'))
* {
* deleteDir('data/public');
* deleteDir('data/private');
* echo 'Above cache list has been cleared! - You can close the window';
* }
* else
* {
* echo 'Chat cache is already empty!';
* }
*/

/* --- flush caches if requested by the Admin --- */
/*
if ($mybb->settings['pfc_mybb__flush_caches'] == "on")
{
if ( @opendir($mybb->settings['pfc_mybb__pfc_path']."/data/private") )
{
deleteDir($mybb->settings['pfc_mybb__pfc_path']."/data/private");
if ($mybb->settings['pfc_mybb__vers1_9_beta_plus'] == 'off')
{
// delete public only if version < 1.9-beta is in use!
deleteDir($mybb->settings['pfc_mybb__pfc_path'].'/data/public');
}
}
// clear pfc_mybb__flush_caches, so it will not repeat without being specified.
$mybb->settings['pfc_mybb__flush_caches'] = "off";
}

function deleteDir($dir)
{
if (substr($dir, strlen($dir)-1, 1) != '/')
$dir .= '/';

//echo $dir.'<br />';

if ($handle = opendir($dir))
{
while ($obj = readdir($handle))
{
if ($obj != '.' && $obj != '..')
{
if (is_dir($dir.$obj))
{
if (!deleteDir($dir.$obj))
{
return false;
}
}
elseif (is_file($dir.$obj))
{
if (!unlink($dir.$obj))
{
return false;
}
}
}
}
closedir($handle);

if (!@rmdir($dir))
{
return false;
}
return true;
}
return false;
}
*/

?>
Bruceconnor Wrote:how do you add a mod ?

i downloaded a free chat thing (is that a chatbox) and i dont know how to add it. I have got my site on createmybb2.com

You have to ask createmybb2 to install it for you.

Third down.
http://www.createmybb.com/why/faq/
We cannot support you if you are hosted with CreateMyBB. Sorry. Sad

As HarryWx said, you need to ask at their support forums. If they say no then you will need to find a new host in order to have that plugin.