[Help] выделение сообщений

Статус
В этой теме нельзя размещать новые ответы.

TecT

Пользователь для ТесТа
Регистрация
25 Фев 2009
Сообщения
457
Реакции
45
Народ подскажите как сделать так чтоб в чате когда мне написали то чтоб сообщение это было на фоне допустим сером, как это сделать вот мой файл shoutbox.php. Помогите пожалуйста а то не могу не как найти.

Код:
<?
/*
// +--------------------------------------------------------------------------+
// | Project:    CyBERhype Tracker                                            |
// +--------------------------------------------------------------------------+
// | This file is part of CyBERhype Tracker.                                  |
// | CyBERhype Tracker is based on TBDev, originally by RedBeard of           |
// | TorrentBits, extensively modified by  Gartenzwerg.                       |
// |                                                                          |
// | CyBERhype Tracker is free software; you can redistribute it and/or modify|
// | it under the terms of the GNU General Public License as published by     |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | CyBERhype Tracker is distributed in the hope that it will be useful,     |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License along  |
// | with CyBERhype Tracker; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// |                                               Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
require_once ("include/bittorrent.php");
dbconn ( false, true );
global $pic_base_url, $CURUSER, $CURGROUP, $ALLGROUPS;
if ($_GET ['archive'])
	validcan ( false, 'can_viewarch', true );
else
	validcan ( false, 'can_viewsb', true );
@header ( "Content-Type: text/html; charset=Windows-1251" );
/*if ($CURUSER) {
	///////////session/////////////////
	sql_query ( "UPDATE users SET page=1 WHERE id = " . $CURUSER ["id"] ) or sqlerr ( __FILE__, __LINE__ );
	///////////////////////////////////


}*/

if ($_GET ["do"] == "shout" && $CURGROUP ['can_shout']) {
	$shout = trim ( ajax_text_convert ( $_GET ["shout"] ) );
	if (trim ( $shout ) == "/prune" && $CURGROUP ['can_dellshout']) {
		sql_query ( "TRUNCATE TABLE shoutbox" ) or sqlerr ( __FILE__, __LINE__ );
		die ( "Сообшений нет" );
	}
	$sender = $CURUSER ["id"];
	if (! empty ( $shout )) {
		$datee = time ();
		sql_query ( "INSERT INTO shoutbox (date,  text, userid) VALUES (" . implode ( ", ", array_map ( "sqlesc", array (
			$datee, 
			$shout, 
			($sender ? $sender : '-1') ) ) ) . ")" ) or sqlerr ( __FILE__, __LINE__ );
	} else
		print ( "<script>alert('Введи сообщение');</script>" );
} elseif ($_GET ["do"] == "delete" && ($CURGROUP ['can_delshout'] || $CURGROUP ['can_dellshout']) && is_valid_id ( $_GET ["id"] )) {
	$id = ( int ) $_GET ["id"];
	if (! $CURGROUP ['can_dellshout'] && $CURGROUP ['can_delshout']) {
		$res = mysql_fetch_array ( sql_query ( 'SELECT userid FROM shoutbox WHERE id = ' . $id ) );
		if ($res ['userid'] == $CURUSER ['id'])
			sql_query ( "DELETE FROM shoutbox WHERE id = $id" ) or sqlerr ( __FILE__, __LINE__ );
	} else
		sql_query ( "DELETE FROM shoutbox WHERE id = $id" ) or sqlerr ( __FILE__, __LINE__ );
}
if (! $_GET ["archive"])
	$limit = "LIMIT 15";
$res = sql_query ( "SELECT shoutbox.*, users.username, users.warned, users.id as uid, users.`group` FROM shoutbox LEFT JOIN users ON shoutbox.userid = users.id ORDER BY id DESC $limit" ) or sqlerr ( __FILE__, __LINE__ );
if (mysql_num_rows ( $res ) == 0)
	die ( "Сообшений нет" );
print ( "\n" );
while ( $arr = mysql_fetch_array ( $res ) ) {
	if ($arr ["userid"] == - 1)
		$arr ["username"] = "Гость";
	elseif (! $arr ["username"])
		$arr ["username"] = "Системное";
	if ($arr ["warned"] == "yes")
		$warn = "<img src=\"" . $pic_base_url . "warned.gif\" alt=\"Warned\"/>";
	else
		$warn = "";
	$username = $arr ["username"];
	$oldtxt = $arr ["text"];
	if ($CURGROUP ['can_ban']) {
		preg_match ( "#enabled\((.*)\)#si", $arr ["text"], $matches );
		$banuser = trim ( $matches [1] );
		if ($CURUSER ['username'] != $banuser && $banuser) {
			// FORUM INTEGRATION MOD //
			$enabled = @mysql_fetch_array ( sql_query ( "SELECT enabled, `group`, username FROM users WHERE username=" . sqlesc ( $banuser ) ) );
			// FORUM INTEGRATION MOD //
			if ($enabled) {
				$all1 = summgroup ( $ALLGROUPS [$enabled ['group']] );
				$all2 = summgroup ( $CURGROUP );
				if ($all2 > $all1 && $ALLGROUPS [$enabled ['group']] ['can_bebanned']) {
					if ($enabled ["enabled"] == "yes") {
						$newstatus = "'no'";
						$status = "забаннил";
					} elseif ($enabled ["enabled"] == "no") {
						$newstatus = "'yes'";
						$status = "разбаннил";
					}
					if ($newstatus) {
						$banres = sql_query ( "UPDATE users SET enabled=$newstatus WHERE username=" . sqlesc ( $banuser ) ) or sqlerr ( __FILE__, __LINE__ );
						// FORUM INTEGRATION MOD //
						if ($enabled ["enabled"] == "yes")
							FORUM_ban ( $enabled ['username'], '', 0 );
						else
							FORUM_unban ( $enabled ['username'] );
							// FORUM INTEGRATION MOD //
						if ($banres) {
							$banres = "";
							$newtxt = $CURUSER ['username'] . ' только что ' . $status . ' ' . $banuser;
							sql_query ( "UPDATE shoutbox SET text=" . sqlesc ( $newtxt ) . " WHERE id=" . $arr ["id"] ) or sqlerr ( __FILE__, __LINE__ );
						}
					}
				}
			}
		}
	}
	if ($newtxt) {
		$arr ["text"] = unesc ( $newtxt );
		$newtxt = "";
	}
	$arr ["text"] = format_comment ( $arr ["text"], true, $ALLGROUPS [$arr ['group']] ['can_usepsmile'] );
	$tag_me = 0;
	if (preg_match ( "/\/me /", $arr ["text"] )) {
		$arr ["text"] = preg_replace ( "/\/me /", get_user_group_color ( $arr ['group'], $arr ['username'] ? $arr ['username'] . " " : "Гость " ), $arr ["text"], 1 );
		$tag_me = 1;
	}
	$icons = "" . (($CURGROUP ['can_delshout'] && $CURUSER ["id"] == $arr ["userid"]) || $CURGROUP ['can_dellshout'] || ($CURUSER ["username"] == $nume && $nume) ? "<span  onclick=\"deleteShout($arr[id]);\" style=\"cursor: pointer; color: red; font-weight: bold; text-decoration: underline\"><img src=\"" . $pic_base_url . "warned2.gif\" style=\"border: 0px;\" /></a></span>" : "") . "
    " . (($CURGROUP ['can_editshout'] && $CURUSER ["id"] == $arr ["userid"]) || $CURGROUP ['can_editlshout'] || ($CURUSER ["username"] == $nume && $nume) ? "<span onclick=\"editShout($arr[id]);\" style=\"cursor: pointer; color: red; font-weight: bold; text-decoration: underline\"><img src=\"" . $pic_base_url . "pen.gif\" style=\"border: 0px;\" /></span>" : "") . "
" . (! $tag_me && $CURUSER ['id'] != $arr ["userid"] ? "<a target=\"_blank\" 
href=\"message.php?action=sendmessage&receiver=" . $arr ['userid'] . "\" title=\"Отправить ЛС\">
<img src=\"" . $pic_base_url . "pn_inbox.gif\" border=\"0\"></a>" . " 
 <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>" : "") . " 
	" . ($CURGROUP ['can_ban'] && $arr ['userid'] != $CURUSER ['id'] && $arr ['userid'] > 0 ? "
 <span onclick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='enabled($username)'+parent.document.shoutform.shout.value;sendShout(shoutform);return false;\" 
	style=\"cursor: pointer; color: red; font-weight: bold;\">B\U</span>" : "") . "
	 " . (! $tag_me ? ($CURGROUP ['can_viewprof'] ? "<a href=userdetails.php?id=" . $arr ["uid"] . " target='_blank'><img src=\"" . $pic_base_url . "info/guest.gif\"  border=0  title=\"Посмотреть профиль\"></a>" : "") . "
	   <a href=\"userdetails.php?id=" . $arr ["uid"] . "\" onClick=\"parent.document.shoutform.shout.focus();parent.document.shoutform.shout.value='[b]" . $username . "[/b]: '+parent.document.shoutform.shout.value;return false;\">
	   " . get_user_group_color ( $arr ["group"], $arr ["username"] ) . "</a>$warn: " : "");
	$arr ["text"] = str_replace ( "[$CURUSER[username]]", "<font color=#000000></font><b style='color: green; 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 ($_GET ["do"] == "edit" && (($arr ['userid'] == $CURUSER ['id'] && $CURGROUP ['can_editshout']) || $CURGROUP ['can_editlshout']) && is_valid_id ( $_GET ["id"] ) && $_GET ['id'] == $arr ['id']) {
		$id = ( int ) $_GET ["id"];
		$edited = $_GET ["shout"];
		if ($edited) {
			$edited = ajax_text_convert ( $edited );
			sql_query ( "UPDATE shoutbox SET text=" . sqlesc ( $edited ) . " WHERE id = $id" ) or sqlerr ( __FILE__, __LINE__ );
			$arr ["text"] = format_comment ( $edited );
		} else {
			$arr ["text"] = ("<font class=\"shout_edit\">" . $arr ['text'] . "</font>");
			if ($_GET ['sub'] != 'ok')
				print ( "<script type=\"text/javascript\">$(\"input[name=shout]\").val('" . addslashes ( $oldtxt ) . "')</script>" );
		}
	} else {
		if (stripos ( $arr ["text"], "privat(" . $CURUSER ["username"] . ")" ) !== false) {
			$arr ["text"] = preg_replace ( "#\\Aprivat\(" . preg_quote ( $CURUSER ["username"] ) . "\)#si", "", $arr ["text"] );
			$arr ["text"] = "<font color=\"red\">*private " . $arr ["text"] . "*</font>";
		} elseif (($CURUSER ["id"] == $arr ["userid"] || ($CURGROUP ['can_admin'] && $CURGROUP ['system'])) and (strpos ( $arr ["text"], "privat(" ) !== false)) {
			$arr ["text"] = preg_replace ( "/\\Aprivat\(([^()<>\s]+?)\)/si", "<b style='color: orange; background: #FFFFFF;'>to {\\1}</b>", $arr ["text"] );
		} elseif (strpos ( $arr ["text"], "privat(" ) !== false) {
			continue;
		}
	}
	if ($tag_me)
		$arr ["text"] = "<font color=\"red\">*" . $arr ["text"] . "*</font>";
	$content [$arr ['id']] .= (! $tag_me ? "<span class='date'>[" . strftime ( "%H:%M:%S", $arr ["date"] ) . "]</span> " : "") . $icons . $arr ["text"] . "<br/>";
}
if ($content) {
	ksort ( $content );
	print ( implode ( "", $content ) );
	print ( '<script language="javascript" type="text/javascript">spoiler_init();</script>' );
}
?>
 
PHP:
<b style='color: orange; background: #FFFFFF;'>
 
это изменяет фон сообщения когда ты пишешь комуто в приват...а мне надо чтоб когда мне написали простое сообщение оно выделилось
 
это изменяет фон сообщения когда ты пишешь комуто в приват...а мне надо чтоб когда мне написали простое сообщение оно выделилось
что-то типо того
PHP:
	if (preg_match ( "/$CURUSER ['username']/", $arr ["text"] )) {
		$arr ["text"] = "<b style='color: orange; background: #FFFFFF;'>".$arr[text]."</b>";
	}
только с кавычками сам разберись )
 
  • Нравится
Реакции: TecT
не подходит...блин чёртов чат!...что только не перепробовал жесть просто!
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху