vBulletin Brasil

vB-Brasil

Comunidade vBulletin em Português

 

Módulo VbChat

Esta é a discussão em Módulo VbChat parte do fórum vB: Mods, addons e Hacks que integra a categoria vBulletin Dúvidas. Participe sempre de nossos debates.


Voltar   vBulletin Brasil > vBulletin Dúvidas > vB: Mods, addons e Hacks

Registrar FAQ Membros Calendário Pesquisar Postados Hoje Marcar Fóruns Como Lidos Especiais!

Notícias

Resposta
 
LinkBack Ferramentas do Tópico Modos de Exibição

  #1 (permalink)  
Antigo 23-11-2007, 18:22
Avatar de Luchiano
Iniciante
 
Registrado em: Oct 2006
Localização: Rio de Janeiro
Idade: 46
Posts: 14
Agradecimentos: 14
Agradecido 7 vez em 3 Posts
Peso da Avaliação : 0
Luchiano ainda não possui pontos de reputação
Padrão Módulo VbChat

Olá boa tarde pessoal,

há tempos venho baixando mods de chat, shoutboxes, etc... Finalmente achei um de acordo com o que eu queria:

(EWT vbchat 2.3)
vBChat v2.3 - vBulletin.org Forum

No entanto, fiz todas as instalações corretamente e tenho um problema quando algum usuário tenta digitar palavras com acentos. Simplesmente trava o chat.

Não sou expert em php e comecei há pouco na plataforma Vbulletin, mas tenho uma noção geral das coisas, então fui fuçar nos aquivos do mod... No código achei um monte de "addslaches" "htmlspecialchars_uni" e outras paradas que eu sei que servem para proteger o chat de injeção de códigos e essas coisas...

Mas essa proteção acaba impedindo que palavras com acento sejam enviadas e trava o chat. Já fucei no MYSQL, já fucei nos codigos dentro das minhas limitações e nada fez os acentos funcionarem...

Será que alguém poderia me ajudar? Não posso postar o mod aqui, mas vou postar os dois arquivos que eu acredito serem os que determinam como o mod deve se comportar com as mensagens enviadas...

Muito obrigado a todos que lerem, e principalmente a quem puder me dar uma luz


VbChat.PHP

Código PHP:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # EWT vBChat System V2.9.2 Legacy File        ||
|| # Originally Created by Zero Tollerance        ||
|| #################################################################### ||
\*======================================================================*/
/*This file is a legacy file for users who are running addons for the chat that utilize its ajax.
This will allow these addons to continue to function.*/
// ---------------------------------------------------
// Start Set PHP Environment
// ---------------------------------------------------
error_reporting(E_ALL & ~E_NOTICE);
// ---------------------------------------------------
// Start Define Important Constants
// ---------------------------------------------------
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''vbchat');
define('LOCATION_BYPASS'1);  
// ---------------------------------------------------
// Start Cache Of Any Needed Templates/Phrase's
// ---------------------------------------------------
$phrasegroups = array();
$specialtemplates = array(
);
$actiontemplates = array(
);

$globaltemplates = array(
);
// ---------------------------------------------------
// Start Require Globalized Settings
// ---------------------------------------------------
require_once('./global.php');
require_once(
'./includes/functions_legacy.php');
legacy_enable();
require_once(
'./includes/functions_user.php');
require_once(
DIR '/includes/class_bbcode.php');
//Setup the bbcode parser since we need it
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
require_once(
'./includes/functions_newpost.php');

$vbulletin->session->db_fields['inchat'] = TYPE_INT;
$vbulletin->session->set('inchat'1);
//Variable Associations for now.
$chat_page "";       // Template Variable

$Chat_Options $vbulletin->db->query_first("select * from ".TABLE_PREFIX."vbchat_datastore where did='1'");
//$Group_Perms  = unserialize($Chat_Options['d_groupperms']);
// ---------------------------------------------------
// End Require Globalized Settings
// ---------------------------------------------------
 // ---------------------------------------------------
 // Start Check vBChat Is Online
 // ---------------------------------------------------
 
if($vbulletin->options['ewt_vbchat_online'] == false){
  
standard_error("Sorry, but the vBChat System has been turned offline, contact the administrator for more information.");
 }
 
// ---------------------------------------------------
 // End Check vBChat Is Online
 // ---------------------------------------------------
 
 // ---------------------------------------------------
 // Start Main Chat Frame
 // ---------------------------------------------------
 
if($_GET['do']=="chatFrame"){
 
// Navigation
 
$navbits     = array("vBChat.php?$session[sessionurl]&do=main" => "vBChat");
 
$navbits[""] = "vBChat";
 
// Cache Possible Usernames For The Chat (Possibility To Save Multiple Queries)
 
$private_cache = array();
 
// Get Ignored Users In Array
 
$Ignore unserialize($vbulletin->userinfo['vbchat_pref_user_ignore']);
  if(
is_array($Ignore) && $vbulletin->userinfo['vbchat_pref_user_ignore'] != ""){
   foreach(
$Ignore as $ig){
   
$Ignoring[] = $ig;
   }
  }
 
$chat_page .= "<table height='100%' border='0'><tr><td colspan\"2\" height=\"100%\"></td></tr>";
  
// Get All Chat Messege's If Any
  
$Get_Chat_MSG $vbulletin->db->query("select u.*,m.* from ".TABLE_PREFIX."vbchat_store m left join ".TABLE_PREFIX."user u on (u.userid = m.s_postby) where m.s_forroom = '{$vbulletin->userinfo['vbchat_pref_in_room']}' order by m.s_postime desc limit 0,20");
 
  while(
$ThisMSG $vbulletin->db->fetch_array($Get_Chat_MSG)){
  
$MSGArray[] = $ThisMSG;
  }
  if(
is_array($MSGArray)){
   
// What order do we like to display the messages?
   
if($vbulletin->options['ewt_vbchat_msgorder'] == "bottom"){
   
$MSGArray array_reverse($MSGArraytrue); // Reverse The Array
   
$do_scroll_auto 1;
   } else {
   
$do_scroll_auto 0;
   }
   foreach(
$MSGArray as $ThisMSG){
    if(
$vbulletin->options['ewt_vbchat_usebbcode'] == true){
     
$ThisMSG['s_message'] = $parser->do_parse($ThisMSG['s_message'], falsetruetruetrue);
    } else {
     
$ThisMSG['s_message'] = htmlspecialchars_uni($ThisMSG['s_message']);
    }
  
    
// Configure Time
    
$ThisMSG['time'] = vbdate($vbulletin->options['timeformat'], $ThisMSG['s_postime']);
    
// WAAAAIT! Is this person ignored?
    
$thisIgnore 0;
    if(
is_array($Ignoring)){
     foreach(
$Ignoring as $CIgnore){
      if(
$CIgnore == $ThisMSG['userid']){
      
$thisIgnore++;
      }
     }
    }
    if(
$ThisMSG['s_postby'] == -1){
    
$BotMsg $ThisMSG['s_message'];
    eval(
'$chat_page .= "' fetch_template('chat_row_bot') . '";');
    } else {
     if(
$thisIgnore == 0){
      if(
substr(strtolower($ThisMSG['s_message']), 03) == "/me"){
      
$ThisMSG['s_message'] = str_replace("/me","",$ThisMSG['s_message']);
      eval(
'$chat_page .= "' fetch_template('chat_row_me') . '";');
      } else {
       
// Is this message for a specific user? - Sender Or Reciever?
       
if($ThisMSG['s_foruser'] > 0){
        if(
$ThisMSG['s_foruser'] == $vbulletin->userinfo['userid']){ // This message is for you only, arn't you special! Not.
        
eval('$chat_page .= "' fetch_template('chat_row_special_recieved') . '";');
        } else if(
$ThisMSG['s_postby'] == $vbulletin->userinfo['userid']){ // You sent this message to someone, lets show its sent. Bit of flirting eh?
        
         // Cached Or Need To Get?
         
if(!$private_cache[$ThisMSG['s_foruser']]){
         
$reciever $vbulletin->db->query_first("select username from ".TABLE_PREFIX."user where userid='{$ThisMSG['s_foruser']}'");
         
// Cache The User
         
$private_cache[$ThisMSG['s_foruser']] = $reciever;
         } else {
         
$reciever $private_cache[$ThisMSG['s_foruser']];
         }
        eval(
'$chat_page .= "' fetch_template('chat_row_special_sent') . '";');
        }
       } else {
       eval(
'$chat_page .= "' fetch_template('chat_row') . '";');
       }
      }
     }
    }
   }
  }
 
$chat_page .= "</table>";
 
$total_users_in_room 0;
 
$chat_upage "";
 
$chat_upage .= "
 <table height='100%' border='0' valign=\"top\">
  <tr>
  <td height='1%'><b>Users Chatting:</b></td>
  </tr>
 "
;
  require_once(
'./includes/functions_user.php');
  
// Any Body Here?
  
$datecut TIMENOW $vbulletin->options['cookietimeout'];
  
$GetUser $vbulletin->db->query("
    SELECT
     user.username, user.vbchat_pref_status, (user.options & $_USEROPTIONS[invisible]) AS invisible, user.usergroupid, user.vbchat_pref_in_room,
     session.userid, session.inforum, session.lastactivity, session.location,
     IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
    FROM " 
TABLE_PREFIX "session AS session
    LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = session.userid)
    WHERE session.lastactivity > $datecut and inchat = 1 and user.vbchat_pref_in_room = '{$vbulletin->userinfo['vbchat_pref_in_room']}'
    " 
iif($vbulletin->options['displayloggedin'] == 1"ORDER BY username ASC") . "
   "
);
  while(
$UserIN $vbulletin->db->fetch_array($GetUser)){
   if(!
$store_c[$UserIN['userid']]){
    if(
$UserIN['userid']){
    
$total_users_in_room++;
    
$store_c[$UserIN['userid']] = "filled";
     if(
trim($UserIN['vbchat_pref_status']) == ""){
     
$UserIN['vbchat_pref_status'] = "<i>None</i>";
     }
    
$chat_upage .= "
    <tr>
    <td height='1%'>
    <table width='100%' border='0' cellpadding='3' cellspacing='1' class='tborder'>
    <tr>
    <td class='thead' align='center'><a href='member.php?{$session['sessionurl']}&u={$UserIN['userid']}' target='_blank'><b id='pri_{$UserIN['userid']}'>{$UserIN['username']}</b></a> <span class=\"smallfont\">(<a href='javascript:MsgUser(\"{$UserIN['userid']}\");' title='Send A Private Chat Message To {$UserIN['username']}'>PM</a>)</span></td>
    </tr>"
;
    if(
$UserIN['vbchat_pref_status']!='<i>None</i>')
    {
     
$chat_upage .= "<tr>
     <td class='alt2' align='center'><b>Status:</b> {$UserIN['vbchat_pref_status']}</td>
     </tr>"
;
    }
    
$chat_upage .= "
    </table>
    </td>
    </tr>"
;
    }
   }
  }
 
$chat_upage .= "<tr><td height=\"100%\"></td></tr></table>";
 eval(
'print_output("' fetch_template('chat_iframe') . '");');
 exit;
 }
 
// ---------------------------------------------------
 // End Main Chat Frame
 // ---------------------------------------------------
 // ---------------------------------------------------
 // Start Post Message
 // ---------------------------------------------------
 
if($_REQUEST['do']=="post_message" || $_POST['do']=="post_message"){
 
  
$vbulletin->input->clean_array_gpc('r', array(
   
'message'          => TYPE_STR,
  ));
  
$message convert_urlencoded_unicode($vbulletin->GPC['message']);

 
$do_msg_insert 1;
  if(
$message != ""){
  
$Special ""// Save var incase were adding additional data
   // Are we msg'ing a specific user?
   
if(substr(strtolower($message), 04) == "/msg" && preg_match("/\/msg \[(.+?)\]/i",$message)){
    
// Lets assume you typed in the correct username or a valid one
    
$msg_user preg_replace("/\/msg \[(.*)\](.*)/i""$1"$message);
    
// Strip The Message
    
$message  preg_replace("/\/msg \[(.*)\](.*)/i""$2"$message);
    
$msg_user trim(addslashes(htmlspecialchars_uni($msg_user)));
     
// Verify User Exists 
     
if($verf_user $vbulletin->db->query_first("select userid,vbchat_pref_auto_on,vbchat_pref_auto_msg from ".TABLE_PREFIX."user where username='{$msg_user}'")){
     
$Special  $verf_user['userid'];
      
// User Has Auto Message On?
      
if($verf_user['vbchat_pref_auto_on']){
      
$verf_user['vbchat_pref_auto_msg'] = "Auto Message: {$verf_user['vbchat_pref_auto_msg']}";
      
$vbulletin->db->query("insert into ".TABLE_PREFIX."vbchat_store (s_postby,s_message,s_postime,s_foruser) values ('{$verf_user['userid']}','".trim(addslashes($verf_user['vbchat_pref_auto_msg']))."',".time().",'{$vbulletin->userinfo['userid']}')");
      }
     }    
   }
   
// Are We Changing Our Status?
   
if(substr(strtolower($message), 7) == "/status" && preg_match("/\/status (.+?)/i",$message)){
   
$NewStatus preg_replace("/\/status (.+?)/i""$1"$message);
   
$status htmlspecialchars_uni(trim(addslashes($NewStatus)));
   
$vbulletin->db->query("update ".TABLE_PREFIX."user set vbchat_pref_status='{$status}' where userid='{$vbulletin->userinfo['userid']}'");
   
// Dont Post The Message
   
$do_msg_insert 0;
   }
   
// Are we banning a user?
   
if(can_moderate(  ) && substr(strtolower($message), 04) == "/ban" && preg_match("/\/ban (.+?)/i",$message) && $vbulletin->options['ewt_vbchat_allowcmds']){
   
// Dont Post The Message
   
$do_msg_insert 0;   
   
// Get the user you desire to ban
   
$ban_user preg_replace("/\/ban (.*)/i""$1"$message);
   
$ban_user trim(addslashes(htmlspecialchars_uni($ban_user)));
    
// Verify User Exists
    
if($verf_user $vbulletin->db->query_first("select userid from ".TABLE_PREFIX."user where username='{$ban_user}'")){
    
$toBan $verf_user['userid'];
    
// Get Current Banned Users Into An Array
    
$Current_Banned explode("|",$Chat_Options['d_bannedusers']);
    
$Already_Banned 0;
     
// User already banned?
     
if(is_array($Current_Banned) && $Chat_Options['d_bannedusers'] != ""){
      foreach(
$Current_Banned as $checkWho){
       if(
$toBan == $checkWho){
       
$Already_Banned++;
       }
      }
     }
     
// Ban Them?
     
if(!$Already_Banned){
      if(
$Chat_Options['d_bannedusers'] != ""){
      
$Current_Banned[] = $toBan;
      
$Current_Banned implode("|",$Current_Banned);
      } else {
      
$Current_Banned $toBan;
      }
     
$vbulletin->db->query("update ".TABLE_PREFIX."vbchat_datastore set d_bannedusers = '{$Current_Banned}' where did='1'");
     }
    }
   }

   
// Are we un-banning a user?
   
if(can_moderate(  ) && substr(strtolower($message), 06) == "/unban" && preg_match("/\/unban (.+?)/i",$message) && $vbulletin->options['ewt_vbchat_allowcmds']){
   
// Dont Post The Message
   
$do_msg_insert 0;   
   
// Get the user you desire to ban
   
$ban_user preg_replace("/\/unban (.*)/i""$1"$message);
   
$ban_user trim(addslashes(htmlspecialchars_uni($ban_user)));
    
// Verify User Exists
    
if($verf_user $vbulletin->db->query_first("select userid from ".TABLE_PREFIX."user where username='{$ban_user}'")){
    
$toUnBan $verf_user['userid'];
    
// Get Current Banned Users Into An Array
    
$Current_Banned explode("|",$Chat_Options['d_bannedusers']);
     
// User already banned?
     
if(is_array($Current_Banned) && $Chat_Options['d_bannedusers'] != ""){
      foreach(
$Current_Banned as $checkWho){
       if(
$toUnBan != $checkWho){
       
$new_banned[] = $checkWho;
       }
      }
     }
     if(!empty(
$new_banned) && $new_banned[1]){
     
$Current_Banned implode("|",$new_banned);
     } else if(!
$new_banned[1]){
     
$Current_Banned $new_banned[0];
     } else {
     
$Current_Banned "";
     }
    
$vbulletin->db->query("update ".TABLE_PREFIX."vbchat_datastore set d_bannedusers = '{$Current_Banned}' where did='1'");
    }
   }
  
   if(
$do_msg_insert){
   
// Insert Message
   
$vbulletin->db->query("insert into ".TABLE_PREFIX."vbchat_store (s_postby,s_message,s_postime,s_foruser,s_forroom) values ('{$vbulletin->userinfo['userid']}','".trim(addslashes($message))."',".time().",'{$Special}','{$vbulletin->userinfo['vbchat_pref_in_room']}')");
   }
  }
 
 
// Redirect
// header("Location: vBChat.php?{$session['sessionurl']}&do=chatFrame");
$bypassoutput true;
echo(
"$message");
 }
 
// ---------------------------------------------------
 // End Post Message
 // ---------------------------------------------------
 

// ---------------------------------------------------
// Start Page Output
// ---------------------------------------------------
if(!$bypassoutput)
{
}
// ---------------------------------------------------
// End Page Output
// ---------------------------------------------------
?>




CHAT.PHP
Código PHP:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # EWT vBChat v2.9.2         ||
|| # Originally Created by Zero Tolerance           ||
|| #################################################################### ||
\*======================================================================*/
// ---------------------------------------------------
// Start Set PHP Environment
// ---------------------------------------------------
error_reporting(E_ALL & ~E_NOTICE);
// ---------------------------------------------------
// Start Define Important Constants
// ---------------------------------------------------
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''vbchat');
define('LOCATION_BYPASS'1);  
// ---------------------------------------------------
// Start Cache Of Any Needed Templates/Phrase's
// ---------------------------------------------------
$phrasegroups = array();
$specialtemplates = array(
 
'smiliecache'
);
$actiontemplates = array(
   
'main' => array(
     
'chat_main',
     ),
   
'chatFrame' => array(
     
'chat_row',
     
'chat_row_me',
     
'chat_row_special_sent',
     
'chat_row_special_recieved',
     
'chat_row_bot',
     ),
   
'preference' => array(
     
'chat_preference',
     ),
   
'room' => array(
     
'chat_rooms',
     ),
   
'create' => array(
     
'chat_create',
     ),
   
'help' => array(
     
'chat_help'
     
),
);

$globaltemplates = array(
 
'CHAT',
 
'chat_navigation',
 
'chat_error',
 
'chat_main',
 
'chat_footer',
 
'chat_iframe',
 
'chat_iframe_blank'
);
// ---------------------------------------------------
// Start Require Globalized Settings
// ---------------------------------------------------
require_once('./global.php');
require_once(
'./includes/functions_legacy.php');
legacy_enable();
require_once(
'./includes/functions_user.php');
require_once(
DIR '/includes/class_bbcode.php');
//Setup the bbcode parser since we need it
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
require_once(
'./includes/functions_newpost.php');

$vbulletin->session->db_fields['inchat'] = TYPE_INT;
$vbulletin->session->set('inchat'1);
//Variable Associations for now.
$chat_page "";       // Template Variable

$Chat_Options $vbulletin->db->query_first("select * from ".TABLE_PREFIX."vbchat_datastore where did='1'");
//$Group_Perms  = unserialize($Chat_Options['d_groupperms']);
// ---------------------------------------------------
// End Require Globalized Settings
// ---------------------------------------------------
 // ---------------------------------------------------
 // Start Globalized Function - BotMessage
 // ---------------------------------------------------
 
function BotMessage($msg "",$room 0){
 global 
$vbulletin;
 
$vbulletin->db->query("insert into ".TABLE_PREFIX."vbchat_store (s_postby,s_message,s_postime,s_foruser,s_forroom) values (-1,'".trim(addslashes($msg))."',".time().",'0','{$room}')");
 }
 
// ---------------------------------------------------
 // End Globalized Function - BotMessage
 // ---------------------------------------------------
 // ---------------------------------------------------
 // Start Check vBChat Is Online
 // ---------------------------------------------------
 
if($vbulletin->options['ewt_vbchat_online'] == false){
  
standard_error("Sorry, but the vBChat System has been turned offline, contact the administrator for more information.");
 }
 if(!(
$permissions['ewt_chat'] & $vbulletin->bf_ugp_ewt_chat['ewt_chat_canusechat']))
 {
  
standard_error("Sorry, but the administrator has disabled your usergroups access to the chat.");
 }

 
// ---------------------------------------------------
 // End Check vBChat Is Online
 // ---------------------------------------------------

// ---------------------------------------------------
// Start Incorrect Page Navigation Set
// ---------------------------------------------------
// Navigation
$navbits     = array();
$navbits[""] = "";
// ---------------------------------------------------
// End Incorrect Page Navigation Set
// ---------------------------------------------------
 // ---------------------------------------------------
 // Start Does The Page Have An Action Specified?
 // ---------------------------------------------------
 
if ((!$_GET['do'] || $_GET['do']=="") && !$_POST['do'] && $_REQUEST['do']=="") {
 
$_GET['do'] = "main";
 }
 
// ---------------------------------------------------
 // End Does The Page Have An Action Specified?
 // ---------------------------------------------------
 // ---------------------------------------------------
 // Start Main Chat Page
 // ---------------------------------------------------
 
if($_GET['do']=="main"){
 if(!(
$permissions['ewt_chat'] & $vbulletin->bf_ugp_ewt_chat['ewt_chat_canusechat']))
 {
  
$canusechat false;
 }
 else
 {
  
$canusechat true;
 }
 
// Navigation
 
$navbits     = array("chat.php?$session[sessionurl]&do=main" => "vBChat");
 
$navbits[""] = "vBChat";
 
// What Room Are You In?
 
$Rooms unserialize($Chat_Options['d_chatrooms']);
 
  if(
$vbulletin->userinfo['vbchat_pref_in_room'] == 0){
  
$InRoom "Default Room";
  } else {
  
$InRoom $Rooms[($vbulletin->userinfo['vbchat_pref_in_room'<