|
#1
|
||||
|
||||
Ajax Chat
Hi this modification is for YSE PRE 6.0
First create block file! Code:
<h2 align="left"> Chat <? if (get_user_class() >= UC_MODERATOR) print(" - <font size=\"-2\">[<a class=altlink href=/clear.php?action=clearshout><b>Отчистить чат</b></a>]</font>"); print("<form action=\"shoutbox.php\" method=\"post\" name=\"shoutform\" onsubmit=\"return sendShout(this);\">"); ?> <table cellspacing="0" cellpadding="5" width="100%" > <tr> <td colspan="2" style="white-space: nowrap" width="100%" > <input type="text" name="shout" style="width: 83%" MAXLENGTH="200" /> <input type="submit" value="Отправить" /> <INPUT TYPE="button" VALUE="Smiles" onClick="javascript:winop()"> </td> </tr> <tr> <td > <div id="shoutbox" style="overflow: auto; height: 350px; width: 100%; padding-top: 0cm"> Загрузка... </div> </td> <td style="white-space: nowrap" valign="top" width="18%"> <div id="wol"> </div> <hr width="100%"> <script type="text/javascript" src="swfobject.js"></script> <div id="flashPlayer"> </div> <script type="text/javascript"> var so = new SWFObject("playerMultipleList.swf", "mymovie", "145", "150", "7", "#FFFFFF"); so.addVariable("autoPlay","no") so.addVariable("playlistPath","playlist1.xml") so.write("flashPlayer"); </script> </td> </tr> <? print("</table>"); print("</form>"); ?> <div id="loading-layer" style="display: none; font-family: Lucida Sans Unicode; font-size: 11px; width: 200px; height: 50px; background: #EDFCEF; padding: 10px; text-align: center; border: 1px solid #000"> <div style="font-weight:bold" id="loading-layer-text"><font color="red"> Отправка. Пожалуйста, подождите...</font></div><br /> <img src="pic/loading.gif" border="0" /> </div> <script language="javascript" type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript"> <!-- function winop() { windop = window.open("moresmiles.php?form=shoutform&text=shout","mywin","height=500,width=600,resizable=no,scrollbars=yes"); } function sendShout(formObj) { /*if (postingShout) { alert('Отправка сообщения...') return false }*/ Shout = formObj.shout.value if (Shout.replace(/ /g, '') == '') { alert('Вы должны вести сообщение!') return false } sb_Clear(); var ajax = new tbdev_ajax(); ajax.onShow (''); //ajax.onShow = function() { }; var varsString = ""; ajax.requestFile = "shoutbox.php"; ajax.setVar("do", "shout"); ajax.setVar("shout", escape(Shout)); ajax.method = 'GET'; ajax.element = 'shoutbox'; ajax.sendAJAX(varsString); return false } function getShouts() { var ajax = new tbdev_ajax(); ajax.onShow = function() { }; var varsString = ""; ajax.requestFile = "shoutbox.php"; ajax.method = 'GET'; ajax.element = 'shoutbox'; ajax.sendAJAX(varsString); setTimeout("getShouts();", 10000); return false } function sb_Clear() { document.forms["shoutform"].shout.value = '' return true; } function getWOL() { var ajax = new tbdev_ajax(); ajax.onShow = function() { }; var varsString = ""; ajax.requestFile = "online.php"; ajax.method = 'GET'; ajax.setVar("wol", 1); ajax.element = 'wol'; ajax.sendAJAX(varsString); setTimeout("getWOL();", 10000); return false } function deleteShout(id) { if (confirm("Вы точно хотите удалить это сообщение?")) { var ajax = new tbdev_ajax(); ajax.onShow = function() { }; var varsString = ""; ajax.requestFile = "shoutbox.php"; ajax.setVar("do", "delete"); ajax.setVar("id", id); ajax.method = 'GET'; ajax.element = 'shoutbox'; ajax.sendAJAX(varsString); } return false } getShouts(); getWOL(); --> </script> Code:
<? require_once("include/bittorrent.php"); dbconn(); loggedinorreturn(); header("Content-Type: text/html; charset=Windows-1251"); if ($CURUSER["schoutboxpos"] == 'no') { echo '<table class=main align=center width=400 border=0 cellpadding=0 cellspacing=0><tr><td align=center class=embedded> </br><h1>Sorry</h1><table width=300px border=1 cellspacing=0 cellpadding=10><tr><td class=text align=center>Yo are BAN from Shoutbox .</td></tr></table></td></tr></table>'; 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<strlen($s); $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("<script>alert('Введи сообщение');</script>"); } 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 = "<img src=\"pic/warned.gif\" alt=\"Warned\"/>"; else $warn = ""; $username = $arr["username"]; $arr["text"] = format_comment($arr["text"]); $arr["text"] = str_replace("[$CURUSER[username]]","<font color=#000000>{</font><b style='color: red; background: #FFFFFF;'>$CURUSER[username]</b><font color=#000000>}</font>",$arr["text"]); $arr["text"] = preg_replace("/\[((\s|.)+?)\]/", "<font color=#000000>[</font><b style='color: black;'>\\1</b><font color=#000000>]</font>", $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])","<b style='color: red; background: #FFFFFF;'>$CURUSER[username]</b>:",$arr["text"]); $arr["text"] = preg_replace("/privat\(([^()<>\s]+?)\)/i","<b style='color: #000000; background: #FFFFFF;'>\\1</b>", $arr["text"]); print("<span style=\"background: #ffffff;\"><font color=#a2a2a2>|".strftime("%H:%M",$arr["date"])."|</font> " . (get_user_class() >= UC_MODERATOR ? "<span onclick=\"deleteShout($arr[id]);\" style=\"cursor: pointer; color: red; font-weight: bold; \">X</span> | " : "") . " <span onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='privat($username) '+parent.document.shoutform.shout.value;return false;\" style=\"cursor: pointer; color: red; font-weight: bold;\">P</span> <b><a class=user href=\"userdetails.php?id=".$arr["uid"]."\" onClick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='[".$username."] '+parent.document.shoutform.shout.value;return false;\">".get_user_class_color($arr["class"], $arr["username"]) . "</a></b>$warn: ".($arr["text"])."</span><br />\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","<b style='color: #000000; background: #FFFFFF;'>\\1</b>", $arr["text"]); print("<span style=\"background: #ffffff;\"><font color=#a2a2a2>|".strftime("%H:%M",$arr["date"])."|</font> " . (get_user_class() >= UC_MODERATOR ? "<span onclick=\"deleteShout($arr[id]);\" style=\"cursor: pointer; color: red; font-weight: bold; \">X</span> | " : "") . " <span onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='privat($username) '+parent.document.shoutform.shout.value;return false;\" style=\"cursor: pointer; color: red; font-weight: bold;\">P</span> <b><a class=user href=\"userdetails.php?id=".$arr["uid"]."\" onClick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='[".$username."] '+parent.document.shoutform.shout.value;return false;\">".get_user_class_color($arr["class"], $arr["username"]) . "</a></b>$warn: ".($arr["text"])."</span><br />\n"); } elseif (strpos($arr["text"], "privat(") !== false) { } else { print("<font color=#a2a2a2>|".strftime("%H:%M",$arr["date"])."|</font> " . (get_user_class() >= UC_MODERATOR ? "<span onclick=\"deleteShout($arr[id]);\" style=\"cursor: pointer; color: red; font-weight: bold; \">X</span> | " : "") . " <span onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='privat($username) '+parent.document.shoutform.shout.value;return false;\" style=\"cursor: pointer; color: red; font-weight: bold;\">P</span> <b><a class=user href=\"userdetails.php?id=".$arr["uid"]."\" onClick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='[".$username."] '+parent.document.shoutform.shout.value;return false;\">".get_user_class_color($arr["class"], $arr["username"]) . "</a></b>$warn: ".($arr["text"])."<br />\n"); } } ?> Code:
<? include_once("include/bittorrent.php"); gzip(); dbconn(); header("Content-Type: text/html; charset=Windows-1251"); print " <div id=\"wol\">"; $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 "<span onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='privat($username) '+parent.document.shoutform.shout.value;return false;\" style=\"cursor: pointer; color: red; font-weight: bold;\">P</span> <a href=userdetails.php?id=$id onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='[$username] '+parent.document.shoutform.shout.value;return false;\" target=_blank>$username</a></br>"; } print "</div>"; ?> Code:
<?php 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('Очистить таблицы','Нажмите <a href="'.$_SERVER['SCRIPT_NAME'].'?action=clearshout">сюда</a> что-бы очистить таблицы.',false); } ?> 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 */; |
The Following User Says Thank You to kp380lv For This Useful Post: | ||
look (25th March 2012)
|
#2
|
|||
|
|||
TRanslate it, here only few guys understand russian language!!!!!
|
#3
|
||||
|
||||
if u are website team member then translate it yourself
|
#4
|
|||
|
|||
i think this is for english support
russian is here [url=http://bit-torrent.kiev.ua] |
#5
|
||||
|
||||
Yeah this is english forum but you can help me translate this mod! :D
|
#6
|
|||
|
|||
I would like to can not russian
i can help to german |
#7
|
||||
|
||||
then learn !
Not learn me! Then translate german! Also this mod will be aivable in 2 or 3 languages |
#8
|
|||
|
|||
|
#9
|
||||
|
||||
better
|
#10
|
|||
|
|||
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. |
Tags |
ajax , chat |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ajax Chat | bestmd | Mods & Themes | 23 | 26th September 2014 12:20 |
Need Ajax chat in PB. | re4ux | xBTiT | 2 | 26th August 2009 21:28 |
private chat | BEST | Community Cafe | 2 | 21st August 2009 19:17 |
AJAX Chat | vertex | Yuna Scatari Edition (YSE) | 1 | 26th June 2008 10:50 |
New ratio with ajax - Ajax 5 star ratings | kp380lv | Yuna Scatari Edition (YSE) | 0 | 23rd June 2008 01:11 |