View file element_include/element_chat.php

File size: 1.92Kb
<?php
	$readcache_chat = readcache($chat_cache);
	if (!is_array($readcache_chat)) $readcache_chat = array();
?>

	<form method="post" action="<?php echo $chat_add; ?>">
		<input class="fdark w98 mb10" type="text" name="text" value="<?php echo $chat_to_user; ?>" size="20" maxlength="255">
			<input type="submit" class="button blue w30" name="submit" value="Отправить"/>
		<a class="small ccc" href="<?php echo $chat_refresh; ?>">Обновить</a>
	</form>
	
<?php


	if (empty($readcache_chat)) 
	{
	echo '<div class="p5 cntr"><span class="small ccc">В чате нету сообщений</span></div>';
	echo '</div>';
	} else {
		krsort($readcache_chat);
		require_once './element_function/element_function_pagination.php';
		$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
		$pagination = pagination(10, $page, count($readcache_chat));
		
		foreach(array_slice($readcache_chat, $pagination['start'], $pagination['num'], true) as $k => $massiv) {
			$chat_user = cache_user($massiv['user_id']);
				$on_off = (!empty($online[$massiv['user_id']])) ? 'online' : 'offline';
			echo '
			<div class="mt5">
			<a class="yellow1 sndr bl" href="/user?id='.$massiv['user_id'].'">
				<span class="small fr pt2 lngreen">'.Timer($massiv['time']).'</span>
				'.ikonka_user($chat_user['lost_race'], $on_off).' <span class="small">'.$chat_user['lost_login'].'</span>
			</a>';
			echo '<span class="small">'.Color_Privilege(2, ReplaceText($user['lost_login'], $massiv['text'])).'</span>';
			echo '<br/><a class="ccc small" href="/chat?to='.$chat_user['lost_login'].'">[Ответить]</a>';
			echo ($user['lost_privilege'] > 0) ? ' <a class="red small" href="/chat?delete='.$k.'">[X]</a> <a class="red small" href="/chat#">[Бан]</a>' : '';
			echo '<br/> </div>';
		}
		
		echo '</div>';
		echo pagination_echo($pagination['page'],$pagination['total'],$chat_page);
	}




?>