Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=97)
-   -   Ajax Chat (http://www.bvlist.com/showthread.php?t=862)

kp380lv 19th August 2008 19:50

Ajax Chat
 
Hi this modification is for YSE PRE 6.0

First create block file!

Code:

Chat
        if (get_user_class() >= UC_MODERATOR)
        print(" - [Отчистить чат]");
print("
");

?>







   

print("


   
   
       
   



   

          Загрузка...
   

   

       


               

   


               



   

");
print("
");

?>





And then create file shoutbox.php

Code:

require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
header("Content-Type: text/html; charset=Windows-1251");


if ($CURUSER["schoutboxpos"] == 'no')
{
echo '


Sorry

Yo are BAN from Shoutbox .
';

exit;
}

if ($CURUSER)
{
///////////session/////////////////
mysql_query("UPDATE users SET page=1 WHERE id = " . $CURUSER["id"]) or sqlerr(__FILE__,__LINE__);
///////////////////////////////////

}

function decode_unicode_url($str) {
    $res = '';

    $i = 0;
    $max = strlen($str) - 6;
    while ($i <= $max) {
        $character = $str[$i];
        if ($character == '%' && $str[$i + 1] == 'u') {
        $value = hexdec(substr($str, $i + 2, 4));
        $i += 6;

        if ($value < 0x0080) // 1 byte: 0xxxxxxx
            $character = chr($value);
        else if ($value < 0x0800) // 2 bytes: 110xxxxx 10xxxxxx
            $character =
                chr((($value & 0x07c0) >> 6) | 0xc0)
                . chr(($value & 0x3f) | 0x80);
        else // 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
            $character =
                chr((($value & 0xf000) >> 12) | 0xe0)
                . chr((($value & 0x0fc0) >> 6) | 0x80)
                . chr(($value & 0x3f) | 0x80);
        } else
            $i++;

        $res .= $character;
    }

    return $res . substr($str, $i);
}

function convert_text($s)
{
 $out = "";

 for ($i=0; $i  {
  $c1 = substr ($s, $i, 1);
  $byte1 = ord ($c1);
  if ($byte1>>5 == 6) // 110x xxxx, 110 prefix for 2 bytes unicode
  {
  $i++;
  $c2 = substr ($s, $i, 1);
  $byte2 = ord ($c2);
  $byte1 &= 31; // remove the 3 bit two bytes prefix
  $byte2 &= 63; // remove the 2 bit trailing byte prefix
  $byte2 |= (($byte1 & 3) << 6); // last 2 bits of c1 become first 2 of c2
  $byte1 >>= 2; // c1 shifts 2 to the right

  $word = ($byte1<<8) + $byte2;
  if ($word==1025) $out .= chr(168);                    // ?
  elseif ($word==1105) $out .= chr(184);                // ?
  elseif ($word>=0x0410 && $word<=0x044F) $out .= chr($word-848); // ?-? ?-?
  else
  {
    $a = dechex($byte1);
    $a = str_pad($a, 2, "0", STR_PAD_LEFT);
    $b = dechex($byte2);
    $b = str_pad($b, 2, "0", STR_PAD_LEFT);
    $out .= "&#x".$a.$b.";";
  }
  }
  else
  {
  $out .= $c1;
  }
 }

 return $out;
}

if ($_GET["do"] == "shout") {
    $shout = convert_text(urldecode(decode_unicode_url($_GET["shout"])));
    if ($shout == "/pearja" && get_user_class() >= UC_ADMINISTRATOR) {
        mysql_query("TRUNCATE TABLE shoutbox");
        die("Сообшений нет");
    }
    $sender = $CURUSER["id"];
    if (!empty($shout)) {
        $shout = preg_replace("/\/me /", $CURUSER["username"]." ", $shout);
$datee=time();
        mysql_query("INSERT INTO shoutbox (date, text, userid) VALUES (".implode(", ", array_map("sqlesc", array($datee, $shout, $sender))).")") or sqlerr(__FILE__,__LINE__);
    } else
        print("");
} elseif ($_GET["do"] == "delete" && get_user_class() >= UC_MODERATOR && is_valid_id($_GET["id"])) {
    $id = $_GET["id"];
    mysql_query("DELETE FROM shoutbox WHERE id = $id") or sqlerr(__FILE__,__LINE__);
}
$res = mysql_query("SELECT shoutbox.*, users.username, users.warned, users.id as uid, users.class FROM shoutbox INNER JOIN users ON shoutbox.userid = users.id ORDER BY id DESC LIMIT 35") or sqlerr(__FILE__,__LINE__);

if (mysql_num_rows($res) == 0)
    die("Сообшений нет");
print("\n");
while ($arr = mysql_fetch_array($res)) {


if ($arr["warned"] == "yes") 
$warn = "\"Warned\"/";
else
$warn = "";
$username = $arr["username"];



$arr["text"] = format_comment($arr["text"]);

$arr["text"] = str_replace("[$CURUSER[username]]","{$CURUSER[username]}",$arr["text"]);

$arr["text"] = preg_replace("/\[((\s|.)+?)\]/", "[\\1]", $arr["text"]);

if (strpos($arr["text"], "privat($CURUSER[username])") !== false) {

$variabila = "privat($CURUSER[username])";
$nume = substr($variabila, 7);
$nume = substr($nume, 0, strlen($nume)-1);

if (($CURUSER["username"] == $nume) || ($CURUSER["id"] == "".$arr["userid"]."")) {

$arr["text"] = str_replace("privat($CURUSER[username])","$CURUSER[username]:",$arr["text"]);

$arr["text"] = preg_replace("/privat\(([^()<>\s]+?)\)/i","\\1", $arr["text"]);

print("|".strftime("%H:%M",$arr["date"])."| " . (get_user_class() >= UC_MODERATOR ? "X | " : "") . " P ".get_user_class_color($arr["class"], $arr["username"]) . "$warn: ".($arr["text"])."\n");
}
} else
if ((($CURUSER["id"] == "".$arr["userid"]."") OR (get_user_class() >= UC_MODERATOR)) AND (get_user_class() >= $arr["class"]) AND (strpos($arr["text"], "privat(") !== false)) {

$arr["text"] = preg_replace("/privat\(([^()<>\s]+?)\)/i","\\1", $arr["text"]);

print("|".strftime("%H:%M",$arr["date"])."| " . (get_user_class() >= UC_MODERATOR ? "X | " : "") . " P ".get_user_class_color($arr["class"], $arr["username"]) . "$warn: ".($arr["text"])."\n");
} elseif (strpos($arr["text"], "privat(") !== false) {
} else {
print("|".strftime("%H:%M",$arr["date"])."| " . (get_user_class() >= UC_MODERATOR ? "X | " : "") . " P ".get_user_class_color($arr["class"], $arr["username"]) . "$warn: ".($arr["text"])."\n");
}
}

?>

Then create online.php

Code:

include_once("include/bittorrent.php");
gzip();
dbconn();

header("Content-Type: text/html; charset=Windows-1251");

print "   
";



$dt = gmtime() - 5;
$dt = sqlesc(get_date_time($dt));
$res = mysql_query("SELECT id, username, class, donor, warned, parked FROM users WHERE last_access >= $dt ORDER BY username") or print(mysql_error());
while ($arr = mysql_fetch_assoc($res)) {

    $username = $arr['username'];
    $id = $arr['id'];

        echo "P $username
";
}
print "
";
?>

Create clear.php too

Code:

require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
    stderr('Ошибка', 'Не достаточно прав.');

$action = ($_POST['action'] ? $_POST['action'] : ($_GET['action'] ? $_GET['action'] : 'start'));

if ($action == 'clearshout') {
    mysql_query('TRUNCATE TABLE shoutbox') or sqlerr(__FILE__, __LINE__);
    stderr('Очистка прошла успешно.','Таблица чата была успешно очищена.');
}elseif ($action == 'start') {
    stderr('Очистить таблицы','Нажмите сюда что-бы очистить таблицы.',false);
}
?>

And add in your database this:

Code:

DROP TABLE IF EXISTS `shoutbox`;
CREATE TABLE `shoutbox` (
  `id` smallint(6) NOT NULL auto_increment,
  `userid` smallint(6) NOT NULL default '0',
  `class` int(11) NOT NULL default '0',
  `username` varchar(25) /*!40101 collate cp1251_bin */ NOT NULL default '',
  `date` int(11) NOT NULL default '0',
  `text` text /*!40101 collate cp1251_bin */ NOT NULL,
  `orig_text` text /*!40101 collate cp1251_bin */ NOT NULL,
  `warned` enum('yes','no') /*!40101 collate cp1251_bin */ NOT NULL default 'no',
  `donor` enum('yes','no') /*!40101 collate cp1251_bin */ NOT NULL default 'no',
  `gender` enum('1','2','3') /*!40101 collate cp1251_bin */ NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1118 /*!40101 DEFAULT CHARSET=cp1251 */ /*!40101 COLLATE=cp1251_bin */;


Nilsons 20th August 2008 12:09

TRanslate it, here only few guys understand russian language!!!!!

kp380lv 20th August 2008 12:11

if u are website team member then translate it yourself

netdsl 20th August 2008 12:35

Quote:

Originally Posted by kp380lv (Post 3595)
if u are website team member then translate it yourself

i think this is for english support


russian is here [url=http://bit-torrent.kiev.ua]

kp380lv 20th August 2008 12:38

Yeah this is english forum but you can help me translate this mod! :D

netdsl 20th August 2008 12:42

I would like to can not russian

i can help to german :tease:

kp380lv 20th August 2008 12:46

then learn !

Not learn me! Then translate german! Also this mod will be aivable in 2 or 3 languages

netdsl 20th August 2008 12:59

Google Übersetzer


better than nothing

kp380lv 20th August 2008 13:00

better

jora33 24th August 2008 13:00

Problem
 
I have a problem on index page in chat is doesn't show The text just
Загрузка... .
And when i type some text and pres enter i am redirected to shoutbox.php and there show Сообшений нет .
And another problem when i paste on
Отчистить чат
its show:

Object Not Found

Thx to that ho will help,
Sorry for my bad English.


All times are GMT +2. The time now is 16:20.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.