Llamarme torpe idiota o lo que sea pero...
Código: Seleccionar todo
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
// Mod Mini classement V1.0.0
if (isset($config['mini_classement_open']) && isset($config['mini_classement_index']))
{
if ($config['mini_classement_open'] && $config['mini_classement_index'])
{
include($phpbb_root_path . 'includes/mini_classement.'.$phpEx);
}
}
// Mod Mini classement V1.0.0
display_forums('', $config['load_moderators']);
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
$total_topics = $config['num_topics'];
$total_users = $config['num_users'];
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . '
WHERE group_legend = 1
ORDER BY group_name ASC';
}
else
{
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON (
g.group_id = ug.group_id
AND ug.user_id = ' . $user->data['user_id'] . '
AND ug.user_pending = 0
)
WHERE g.group_legend = 1
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$legend = array();
while ($row = $db->sql_fetchrow($result))
{
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
{
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
}
else
{
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
}
}
$db->sql_freeresult($result);
$legend = implode(', ', $legend);
// Generate birthday list if required ...
$birthday_list = '';
$bd_list_ary = $bd_list_log_ary = array();
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday, u.user_email, u.user_lang,u.user_notify_type, u.user_jabber
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1)
AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
}
if (trim($row['user_email']) && $config['birthday_emails'])
{
$bd_list_ary[] = array(
'method' => $row['user_notify_type'],
'email' => $row['user_email'],
'jabber' => $row['user_jabber'],
'name' => $row['username'],
'lang' => $row['user_lang']
);
}
}
$db->sql_freeresult($result);
$check_time_bdemail = (int) gmdate('mdY',time() + (3600 * ($config['board_timezone'] + $config['board_dst'])));
if ( sizeof($bd_list_ary) && ($user->data['user_timezone'] == $config['board_timezone'] && $user->data['user_dst'] == $config['board_dst']) && ($config['birthday_run'] != $check_time_bdemail) && $config['birthday_emails'] )
{
set_config('birthday_run', $check_time_bdemail);
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
$messenger = new messenger();
foreach ($bd_list_ary as $pos => $addr)
{
$messenger->template('birthday_email', $addr['lang']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
// if you want to receive copies of the birthday emails, just uncomment below line
//$messenger->cc('your@email.com', 'your_name');
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($addr['name'])
));
$messenger->send($addr['method']);
$bd_list_log_ary[] = $addr['name'];
}
add_log('admin', 'LOG_BIRTHDAY_EMAIL_SENT', implode(', ', $bd_list_log_ary));
unset($bd_list_ary);
unset($bd_list_log_ary);
$messenger->save_queue();
unset($messenger);
}
}
if (!function_exists('display_who_was_here'))
{
include($phpbb_root_path . 'includes/functions_wwh.' . $phpEx);
}
display_who_was_here();
// Assign index specific vars
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'LEGEND' => $legend,
'BIRTHDAY_LIST' => $birthday_list,
'FORUM_IMG' => $user->img('forum_read', 'NO_NEW_POSTS'),
'FORUM_NEW_IMG' => $user->img('forum_unread', 'NEW_POSTS'),
'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
'FORUM_NEW_LOCKED_IMG' => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
/* ============= mChat Start ============= */
if(!defined('MCHAT_INCLUDE'))
{
define('MCHAT_INCLUDE', true);
$mchat_include_index = true;
include($phpbb_root_path.'mchat.'.$phpEx);
}
/* ============== mChat End ============== */
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
page_footer();
?>
Código: Seleccionar todo
<?php
/**
*
* @package mChat PHP Code
* @version 1.2.6 of 22.05.2009
* @copyright (c) By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
**/
/**
* DO NOT CHANGE (IN_PHPBB)!
*/
if(!defined('MCHAT_INCLUDE'))
{
// Custom Page code from http://www.phpbb.com/kb/article/add-a-new-custom-page-to-phpbb/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path.'common.'.$phpEx);
$mchat_include_index = false;
// Start session management.
$user->session_begin();
$auth->acl($user->data);
$user->setup();
}
// Add lang file and name for db
$user->add_lang(array('mods/mchat_lang', 'viewtopic'));
define('MCHAT_TABLE', $table_prefix.'mchat');
// Options (global)
$mchat_enable = true; /* Enable this mChat? */
$mchat_refresh_time = 5; /* Auto Update time in seconds (recommended from 10 to 45). */
$mchat_message_limit = 15; /* The maximum number of messages in index page (recommended from 10 to 20). */
$mchat_archive_limit = 30; /* The maximum number of messages in archive page (recommended from 10 to 50). */
$mchat_secret_code = '7g4sgO62AN6MVMa'; /* Secret code for installation and removal mChat from a database (only latin letters and numbers). */
$mchat_flood_time = 5; /* Flood control time in seconds (recommended from 5 to 30). (set 0 to disable) */
$mchat_allow_urls = true; /* Convert the addresses of sites to links? */
$mchat_allow_smilies = true; /* Allow to use smilies? */
$mchat_color_nick = false; /* Colored nicks in the treatment. */
$mchat_message_max_length = 500; /* The maximum number of characters in message (recommended from 100 to 1000). (set 0 to disable) */
$mchat_not_allowed_bbcodes = ''; /* Not allowed bbcodes for use in mChat (separate bbcodes with a vertical bar, example: 'b|u|code'). (set empty to disable) */
$mchat_use_custom_page = true; /* Use the chat on mchat.php page? */
$mchat_use_custom_page_whois = true; /* Show who is online on board to custom page? */
$mchat_date_format = 'd M Y, H:i'; /* Date format for show in messages. (set empty to use default date by board or user setting) */
$mchat_message_max_word = 100; /* Maximum length of words in message (recommended from 50 to 150). (set 0 to disable) */
// Options (admin)
$mchat_allow_admin_edit = true; /* Allow editing messages? */
$mchat_allow_admin_del = true; /* Allow delete messages? */
$mchat_allow_admin_ip = true; /* Allow view IP addres of message posted? */
$mchat_allow_admin_bbcode = true; /* Allow use bbcodes in messages? */
$mchat_admin_no_flood = true; /* Allow ignore flood control? */
// Options (moder)
$mchat_allow_moder_edit = false; /* Allow editing messages? */
$mchat_allow_moder_del = true; /* Allow delete messages? */
$mchat_allow_moder_ip = true; /* Allow view IP addres of message posted? */
$mchat_allow_moder_bbcode = true; /* Allow use bbcodes in messages? */
$mchat_moder_no_flood = true; /* Allow ignore flood control? */
// Options (user)
$mchat_allow_user_bbcode = true; /* Allow use bbcodes in messages? */
$mchat_allow_user_add_mess = true; /* Allow add message? */
$mchat_allow_user_read_archive = true; /* Allow read archive? */
// Options (guest)
$mchat_allow_guest_bbcode = false; /* Allow use bbcodes in messages? */
$mchat_allow_guest_add_mess = false; /* Allow add message? */
$mchat_allow_guest_read_archive = false; /* Allow read archive? */
// Access rights (generated from options)
$mchat_allow_bbcode = ($config['allow_bbcode'] == 1 && (($mchat_allow_admin_bbcode && $auth->acl_get('a_')) || ($mchat_allow_moder_bbcode && $auth->acl_get('m_')) || ($mchat_allow_user_bbcode && $auth->acl_get('u_') && $user->data['is_registered']) || ($mchat_allow_guest_bbcode && $user->data['user_id'] == ANONYMOUS))) ? true : false;
$mchat_edit = (($mchat_allow_admin_edit && $auth->acl_get('a_')) || ($mchat_allow_moder_edit && $auth->acl_get('m_'))) ? true : false;
$mchat_del = (($mchat_allow_admin_del && $auth->acl_get('a_')) || ($mchat_allow_moder_del && $auth->acl_get('m_'))) ? true : false;
$mchat_ip = (($mchat_allow_admin_ip && $auth->acl_get('a_')) || ($mchat_allow_moder_ip && $auth->acl_get('m_'))) ? true : false;
$mchat_add_mess = (($mchat_allow_user_add_mess && $auth->acl_get('u_') && $user->data['is_registered']) || ($mchat_allow_guest_add_mess && $user->data['user_id'] == ANONYMOUS)) ? true : false;
$mchat_no_flood = (($mchat_admin_no_flood && $auth->acl_get('a_')) || ($mchat_moder_no_flood && $auth->acl_get('m_'))) ? true : false;
$mchat_smilies = ($mchat_allow_smilies && $config['allow_smilies'] == 1) ? true : false;
$mchat_urls = ($mchat_allow_urls && $config['allow_post_links'] == 1) ? true : false;
$mchat_read_archive = (($mchat_allow_user_read_archive && $auth->acl_get('u_') && $user->data['is_registered']) || ($mchat_allow_guest_read_archive && $user->data['user_id'] == ANONYMOUS)) ? true : false;
$mchat_founder = ($user->data['user_type'] != USER_FOUNDER) ? false : true;
// Reguest options.
$mchat_mode = request_var('mode', '');
$mchat_read_mode = false;
$mchat_archive_mode = false;
$mchat_custom_page = false;
$mchat_index_redirect = append_sid("{$phpbb_root_path}index.$phpEx");
// Request mode...
switch ($mchat_mode)
{
// Install DB function...
case 'install':
// Reguest...
$mchat_secret_code_req = request_var('code', '');
// User logged in?
if(!$user->data['is_registered'])
{
// Login box...
login_box('', $user->lang['LOGIN']);
}
// No founder!
else if(!$mchat_founder)
{
// Show not authorized box
trigger_error('NO_AUTH_OPERATION', E_USER_WARNING);
}
// Founder!
else if($mchat_founder && $mchat_secret_code == $mchat_secret_code_req)
{
// Drop db if exist befor install!
$sql = 'DROP TABLE IF EXISTS '.MCHAT_TABLE;
$db->sql_query($sql);
// Run install db!
$sql = 'CREATE TABLE '.MCHAT_TABLE.'(message_id mediumint(8) unsigned NOT NULL auto_increment, user_id mediumint(8) unsigned NOT NULL default \'0\', username varchar(255) collate utf8_bin NOT NULL default \'\', user_colour varchar(6) collate utf8_bin NOT NULL default \'\', user_ip varchar(40) collate utf8_bin NOT NULL default \'\', message mediumtext character set utf8 collate utf8_unicode_ci NOT NULL, bbcode_bitfield varchar(255) collate utf8_bin NOT NULL default \'\', bbcode_uid varchar(8) collate utf8_bin NOT NULL default \'\', bbcode_options tinyint(1) unsigned NOT NULL default \'7\', message_time int(11) unsigned NOT NULL default \'0\', PRIMARY KEY (message_id)) DEFAULT CHARSET=utf8 COLLATE=utf8_bin';
$db->sql_query($sql);
// Show OK box and redirect to index page
meta_refresh(3, $mchat_index_redirect);
trigger_error($user->lang['MCHAT_INSTALLOK'].'<br /><br />'.sprintf($user->lang['RETURN_PAGE'], '<a href="'.$mchat_index_redirect.'">', '</a>'), E_USER_NOTICE);
}
else
{
// Show error box...
trigger_error('MCHAT_INSTALLERROR', E_USER_ERROR);
}
// Stop run code!
exit;
break;
// Uninstall DB function...
case 'uninstall':
// Reguest...
$mchat_secret_code_req = request_var('code', '');
// User logged in?
if(!$user->data['is_registered'])
{
// Login box...
login_box('', $user->lang['LOGIN']);
}
// No founder!
else if(!$mchat_founder)
{
// Show not authorized
trigger_error('NO_AUTH_OPERATION', E_USER_WARNING);
}
// Founder!
else if($mchat_founder && $mchat_secret_code == $mchat_secret_code_req)
{
// Run Uninstall!
$sql = 'DROP TABLE '.MCHAT_TABLE;
$db->sql_query($sql);
// Show OK box and redirect to index page
meta_refresh(3, $mchat_index_redirect);
trigger_error($user->lang['MCHAT_UNINSTALLOK'].'<br /><br />'.sprintf($user->lang['RETURN_PAGE'], '<a href="'.$mchat_index_redirect.'">', '</a>'), E_USER_NOTICE);
}
else
{
// Show error box...
trigger_error('MCHAT_UNINSTALLERROR', E_USER_ERROR);
}
// Stop run code!
exit;
break;
// Clean function...
case 'clean';
// User logged in?
if(!$user->data['is_registered'])
{
// Login box...
login_box('', $user->lang['LOGIN']);
}
// No founder!
else if(!$mchat_founder)
{
// Show not authorized
trigger_error('NO_AUTH_OPERATION', E_USER_WARNING);
}
// Founder!
else if($mchat_founder)
{
if(confirm_box(true))
{
// Run cleaner
$sql = 'TRUNCATE TABLE '.MCHAT_TABLE;
$db->sql_query($sql);
// Show OK box and redirect to index page
meta_refresh(3, $mchat_index_redirect);
trigger_error($user->lang['MCHAT_CLEANED'].'<br /><br />'.sprintf($user->lang['RETURN_PAGE'], '<a href="'.$mchat_index_redirect.'">', '</a>'), E_USER_NOTICE);
}
else
{
// Display confirm box
confirm_box(false, $user->lang['MCHAT_DELALLMESS']);
}
redirect($mchat_index_redirect);
}
else
{
// Show error box...
trigger_error('MCHAT_NOACCESS', E_USER_NOTICE);
}
// Stop run code!
exit;
break;
// Archive function...
case 'archive';
if($mchat_enable && $mchat_read_archive)
{
// Reguest...
$mchat_archive_start = request_var('start', 0);
// Message row
$sql = 'SELECT * FROM '.MCHAT_TABLE.' ORDER BY message_id DESC';
$result = $db->sql_query_limit($sql, $mchat_archive_limit, $mchat_archive_start);
$rows = $db->sql_fetchrowset($result);
foreach($rows as $row)
{
$message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '"', $message_edit); // Edit Fix ;)
$template->assign_block_vars('mchatrow', array(
'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USER_IP' => $row['user_ip'],
'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
'MCHAT_TIME' => $user->format_date($row['message_time'], $mchat_date_format),
'MCHAT_CLASS' => ($row['message_id'] % 2) ? 1 : 2
));
}
$db->sql_freeresult($result);
// Write no message
if(empty($rows))
{
// Template function...
$template->assign_vars(array('MCHAT_NOMESSAGE_MODE' => true));
}
// Run query again to get the total message rows...
$sql = 'SELECT COUNT(message_id) AS mess_id FROM '.MCHAT_TABLE;
$result = $db->sql_query($sql);
$mchat_total_message = $db->sql_fetchfield('mess_id');
$db->sql_freeresult($result);
// Page list function...
$template->assign_vars(array(
'MCHAT_PAGE_NUMBER' => on_page($mchat_total_message, $mchat_archive_limit, $mchat_archive_start),
'MCHAT_TOTAL_MESSAGES' => sprintf($user->lang['MCHAT_TOTALMESSAGES'], $mchat_total_message),
'MCHAT_PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mchat.$phpEx", 'mode=archive'), $mchat_total_message, $mchat_archive_limit, $mchat_archive_start, true)
));
// If archive mode request set true
$mchat_archive_mode = true;
}
else if(!$mchat_read_archive)
{
// Redirect to index page
meta_refresh(3, $mchat_index_redirect);
trigger_error($user->lang['MCHAT_NOACCESS'].'<br /><br />'.sprintf($user->lang['RETURN_PAGE'], '<a href="'.$mchat_index_redirect.'">', '</a>'), E_USER_NOTICE);
// Stop run code!
exit;
}
// If archive mode request set true
$mchat_archive_mode = true;
break;
// Read function...
case 'read':
// Reguest...
$mchat_message_last_id = request_var('message_last_id', 0);
// If mChat disabled
if(!$mchat_enable)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
$sql = 'SELECT * FROM '.MCHAT_TABLE.' WHERE message_id > '.$mchat_message_last_id.' ORDER BY message_id DESC';
$result = $db->sql_query_limit($sql, $mchat_message_limit);
$rows = $db->sql_fetchrowset($result);
foreach($rows as $row)
{
$message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '"', $message_edit); // Edit Fix ;)
$template->assign_block_vars('mchatrow', array(
'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USER_IP' => $row['user_ip'],
'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
'MCHAT_TIME' => $user->format_date($row['message_time'], $mchat_date_format),
'MCHAT_CLASS' => ($row['message_id'] % 2) ? 1 : 2
));
}
$db->sql_freeresult($result);
// If read mode request set true
$mchat_read_mode = true;
break;
// Add function...
case 'add':
// If mChat disabled
if(!$mchat_enable)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
// Reguest...
$message = utf8_normalize_nfc(request_var('message', '', true));
if(!$message)
{
// Not Implemented (for jQ AJAX request)
header('HTTP/1.0 501 Not Implemented');
// Stop run code!
exit('HTTP/1.0 501 Not Implemented');
}
if(!$mchat_add_mess)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
// Flood control
if(!$mchat_no_flood)
{
$mchat_flood_current_time = time();
$sql = 'SELECT MAX(message_time) AS last_time FROM '.MCHAT_TABLE.' WHERE user_id = '.$user->data['user_id'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if($row['last_time'] > 0 && ($mchat_flood_current_time - $row['last_time']) < $mchat_flood_time)
{
// Locked (for jQ AJAX request)
header('HTTP/1.0 400 Bad Request');
// Stop run code!
exit('HTTP/1.0 400 Bad Request');
}
$db->sql_freeresult($result);
}
// Words limit
$message = ($mchat_message_max_word != 0) ? utf8_wordwrap($message, $mchat_message_max_word, ' ', true) : $message;
// Message limit
$message = ($mchat_message_max_length != 0 && utf8_strlen($message) >= $mchat_message_max_length + 3) ? utf8_substr($message, 0, $mchat_message_max_length).'...' : $message;
// Add function part code from http://wiki.phpbb.com/Parsing_text
$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
// Not allowed bbcodes
if($mchat_allow_bbcode && $mchat_not_allowed_bbcodes && preg_match('#'.$mchat_not_allowed_bbcodes.':'.$uid.'#', $message))
{
$message = preg_replace('#('.$mchat_not_allowed_bbcodes.'):'.$uid.'#', '$1', $message);
}
$sql_ary = array(
'user_id' => $user->data['user_id'],
'username' => $user->data['username'],
'user_colour' => $user->data['user_colour'],
'user_ip' => $user->data['session_ip'],
'message' => $message,
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'bbcode_options' => $options,
'message_time' => time()
);
$sql = 'INSERT INTO '.MCHAT_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
// Stop run code!
exit;
break;
// Edit function...
case 'edit':
// If mChat disabled
if(!$mchat_enable)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
// Reguest...
$message_id = request_var('message_id', 0);
$message = utf8_normalize_nfc(request_var('message', '', true));
// Stop run delete!
if(!$message_id || !$mchat_edit)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
if(!$message)
{
// Not Implemented (for jQ AJAX request)
header('HTTP/1.0 501 Not Implemented');
// Stop run code!
exit('HTTP/1.0 501 Not Implemented');
}
// Words limit
$message = ($mchat_message_max_word != 0) ? utf8_wordwrap($message, $mchat_message_max_word, ' ', true) : $message;
// Message limit
$message = ($mchat_message_max_length != 0 && utf8_strlen($message) >= $mchat_message_max_length + 3) ? utf8_substr($message, 0, $mchat_message_max_length).'...' : $message;
// Edit function part code from http://wiki.phpbb.com/Parsing_text
$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
// Not allowed bbcodes
if($mchat_allow_bbcode && $mchat_not_allowed_bbcodes && preg_match('#'.$mchat_not_allowed_bbcodes.':'.$uid.'#', $message))
{
$message = preg_replace('#('.$mchat_not_allowed_bbcodes.'):'.$uid.'#', '$1', $message);
}
$sql_ary = array(
'message' => $message,
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'bbcode_options' => $options
);
$sql = 'UPDATE '.MCHAT_TABLE.' SET '.$db->sql_build_array('UPDATE', $sql_ary).' WHERE message_id = '.$message_id;
$db->sql_query($sql);
// Message edited read
$sql = 'SELECT * FROM '.MCHAT_TABLE.' WHERE message_id = '.$message_id.' ORDER BY message_id DESC';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '"', $message_edit); // Edit Fix ;)
$template->assign_block_vars('mchatrow', array(
'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USER_IP' => $row['user_ip'],
'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
'MCHAT_TIME' => $user->format_date($row['message_time'], $mchat_date_format),
'MCHAT_CLASS' => ($row['message_id'] % 2) ? 1 : 2
));
$db->sql_freeresult($result);
// If read mode request set true
$mchat_read_mode = true;
break;
// Delete function...
case 'delete':
// If mChat disabled
if(!$mchat_enable)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
// Reguest...
$message_id = request_var('message_id', 0);
// Stop run delete!
if(!$message_id || !$mchat_del)
{
// Forbidden (for jQ AJAX request)
header('HTTP/1.0 403 Forbidden');
// Stop run code!
exit('HTTP/1.0 403 Forbidden');
}
// Run delete!
$sql = 'DELETE FROM '.MCHAT_TABLE.' WHERE message_id = '.$message_id;
$db->sql_query($sql);
// Stop run code!
exit;
break;
// Default function...
default:
// If not include in index.php set mchat.php page true
if(!$mchat_include_index)
{
// Yes its custom page...
$mchat_custom_page = true;
// if $mchat_use_custom_page_whois true
if($mchat_use_custom_page_whois)
{
// Grab group details for legend display for who is online on the custom page.
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type FROM '.GROUPS_TABLE.' WHERE group_legend = 1 ORDER BY group_name ASC';
}
else
{
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g LEFT JOIN '.USER_GROUP_TABLE.' ug ON (g.group_id = ug.group_id AND ug.user_id = '.$user->data['user_id'].' AND ug.user_pending = 0) WHERE g.group_legend = 1 AND (g.group_type <> '.GROUP_HIDDEN.' OR ug.user_id = '.$user->data['user_id'].') ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$legend = array();
while ($row = $db->sql_fetchrow($result))
{
$colour_text = ($row['group_colour']) ? ' style="color:#'.$row['group_colour'].'"' : '';
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_'.$row['group_name']] : $row['group_name'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
{
$legend[] = '<span'.$colour_text.'>'.$group_name.'</span>';
}
else
{
$legend[] = '<a'.$colour_text.' href="'.append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g='.$row['group_id']).'">'.$group_name.'</a>';
}
}
$db->sql_freeresult($result);
$legend = implode(', ', $legend);
// Assign index specific vars
$template->assign_vars(array('LEGEND' => $legend));
}
}
// If custom page false mchat.php page redirect to index...
if(!$mchat_use_custom_page && $mchat_custom_page)
{
// Redirect to index page
meta_refresh(3, $mchat_index_redirect);
trigger_error($user->lang['MCHAT_NOACCESS'].'<br /><br />'.sprintf($user->lang['RETURN_PAGE'], '<a href="'.$mchat_index_redirect.'">', '</a>'), E_USER_NOTICE);
// Stop run code!
exit;
}
// Run code...
if($mchat_enable)
{
// Message row
$sql = 'SELECT * FROM '.MCHAT_TABLE.' ORDER BY message_id DESC';
$result = $db->sql_query_limit($sql, $mchat_message_limit);
$rows = $db->sql_fetchrowset($result);
foreach($rows as $row)
{
$message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '"', $message_edit); // Edit Fix ;)
$template->assign_block_vars('mchatrow', array(
'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
'MCHAT_USER_IP' => $row['user_ip'],
'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
'MCHAT_TIME' => $user->format_date($row['message_time'], $mchat_date_format),
'MCHAT_CLASS' => ($row['message_id'] % 2) ? 1 : 2
));
}
$db->sql_freeresult($result);
// Write no message
if(empty($rows))
{
// Template function...
$template->assign_vars(array('MCHAT_NOMESSAGE_MODE' => true));
}
// Smile row
if($mchat_smilies)
{
$sql = 'SELECT * FROM '.SMILIES_TABLE.' WHERE display_on_posting = 1 ORDER BY smiley_order';
$result = $db->sql_query($sql, 3600);
$smilies = array();
while ($row = $db->sql_fetchrow($result))
{
if(empty($smilies[$row['smiley_url']]))
{
$smilies[$row['smiley_url']] = $row;
}
}
$db->sql_freeresult($result);
$rows = $db->sql_fetchrowset($result);
if(sizeof($smilies))
{
foreach($smilies as $row)
{
$template->assign_block_vars('mchatsmilerow', array(
'MCHAT_SMILE_CODE' => $row['code'],
'MCHAT_SMILE_EMOTION' => $row['emotion'],
'MCHAT_SMILE_IMG' => $phpbb_root_path.$config['smilies_path'].'/'.$row['smiley_url'],
'MCHAT_SMILE_WIDTH' => $row['smiley_width'],
'MCHAT_SMILE_HEIGHT' => $row['smiley_height']
));
}
}
else
{
$template->assign_vars(array('MCHAT_NO_SMILE' => true));
}
}
}
break;
}
// Template function...
$template->assign_vars(array(
'MCHAT_FILE_NAME' => append_sid("{$phpbb_root_path}mchat.$phpEx"),
'MCHAT_REFRESH_JS' => 1000 * $mchat_refresh_time,
'MCHAT_REFRESH_HTML' => sprintf($user->lang['MCHAT_AUTOUPDATE'], $mchat_refresh_time),
'MCHAT_READ_MODE' => $mchat_read_mode,
'MCHAT_ARCHIVE_MODE' => $mchat_archive_mode,
'MCHAT_ALLOW_SMILES' => $mchat_smilies,
'MCHAT_ALLOW_EDIT' => $mchat_edit,
'MCHAT_ALLOW_DEL' => $mchat_del,
'MCHAT_ALLOW_IP' => $mchat_ip,
'MCHAT_ALLOW_BBCODES' => ($mchat_allow_bbcode && $config['allow_bbcode'] == 1) ? true : false,
'MCHAT_ENABLE' => $mchat_enable,
'MCHAT_COLOR_NICK' => $mchat_color_nick,
'MCHAT_ARCHIVE_URL' => append_sid("{$phpbb_root_path}mchat.$phpEx", 'mode=archive'),
'MCHAT_CUSTOM_PAGE' => $mchat_custom_page,
'MCHAT_READ_ARCHIVE_BUTTON' => $mchat_read_archive,
'MCHAT_CUSTOM_PAGE_WHOIS' => $mchat_use_custom_page_whois,
'MCHAT_FOUNDER' => $mchat_founder,
'MCHAT_CLEAN_URL' => append_sid("{$phpbb_root_path}mchat.$phpEx", 'mode=clean')
));
// Template
if(!$mchat_include_index)
{
page_header($user->lang['MCHAT_TITLE']);
$template->set_filenames(array('body' => 'mchat_body.html'));
page_footer();
}
?>