本文整理汇总了PHP中Chat::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::getMessages方法的具体用法?PHP Chat::getMessages怎么用?PHP Chat::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::getMessages方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
$room = intval($_POST['room']);
$game = intval($_POST['game']);
$loggedUser = LoggedUser::whoIsLogged();
$lastActivity = Room::getUserLastActivityInRoom($loggedUser['id'], $room);
Room::updateUserLastActivity($loggedUser['id'], $room);
MySmarty::assign('messages', Chat::getMessages($room, $loggedUser['id'], 0, $game));
echo MySmarty::fetch('message-box.tpl');
}
示例2: setup
protected function setup()
{
$loggedUser = LoggedUser::whoIsLogged();
if ($this->room !== NULL) {
Room::addUser($loggedUser['id'], $this->room['id']);
$messages = Chat::getMessages($this->room['id'], $loggedUser['id'], 0, $this->game['id']);
MySmarty::assign('loggedUser', $loggedUser);
MySmarty::assign('messages', $messages);
MySmarty::assign('users', Room::getUsers($this->room['id']));
MySmarty::assign('emoticonDir', EMOTICONS_DIR);
MySmarty::assign('emoticons', Emoticons::getEmoticons());
MySmarty::assign('room', $this->room);
}
}
示例3: intval
$actualUrl = Utils::getActualUrl();
$room = intval($_GET['id']);
if (!$room) {
Utils::redirect('rooms.php');
}
Room::addUser($loggedUser['id'], $room);
$gameRepository = new GameRepository();
$game = $gameRepository->getOneByRoom($room);
if ($game) {
$GLOBALS['smarty']->assign('game', $game);
}
if ($_POST && trim($_POST['message'])) {
if (strpos($_POST['message'], '.') === 0) {
$commandResult = Command::execute($_POST['message'], $game);
} else {
Chat::addMessage(trim($_POST['message']), $room);
}
Room::updateUserLastActivity($loggedUser['id'], $room);
Utils::redirect($actualUrl);
}
$messages = Chat::getMessages($room, $loggedUser['id']);
$emoticons = Emoticons::getEmoticons();
$GLOBALS['smarty']->assign('loggedUser', $loggedUser);
$GLOBALS['smarty']->assign('room', $room);
$GLOBALS['smarty']->assign('messages', $messages);
$GLOBALS['smarty']->assign('users', Room::getUsers($room));
$GLOBALS['smarty']->assign('emoticonDir', EMOTICONS_DIR);
$GLOBALS['smarty']->assign('emoticons', $emoticons);
$GLOBALS['smarty']->assign('content', $GLOBALS['smarty']->fetch('room.tpl'));
$GLOBALS['smarty']->assign('bodyAdded', 'onload="JavaScript:timedRefresh(10000, ' . $room . ');"');
echo $GLOBALS['smarty']->fetch('content.tpl');
示例4: Chat
<?php
require 'chat.php';
date_default_timezone_set('Asia/Manila');
session_start();
$chatApp = new Chat();
$action = $chatApp->escapeString($_POST['action']);
if ($action == '670b6594b0d31fe3cb808084a4c9c0cb') {
$chatApp->setQuery("SELECT * FROM logs ORDER BY Date_Time_Added");
while ($row = $chatApp->getMessages('array')) {
if ($row['Type'] == 'Chat') {
if ($row['Username'] == $_SESSION['user_id']) {
echo '<div class="me"><div class="name">You</div><div class="content">' . $row['Message'] . '</div><span class="arrow"></span><div class="time">' . date('F d, Y (h:i A)', strtotime($row['Date_Time_Added'])) . '</div></div>';
} else {
echo '<div class="other"><div class="name">' . $row['Username'] . '</div><div class="content">' . $row['Message'] . '</div><div class="time">' . date('F d, Y (h:i A)', strtotime($row['Date_Time_Added'])) . '</div></div>';
}
} else {
if ($row['Type'] == 'System Log') {
echo '<div class="system"><div class="content">' . $row['Username'] . ' ' . $row['Message'] . '</div><div class="time">' . date('F d, Y (h:i A)', strtotime($row['Date_Time_Added'])) . '</div></div>';
}
}
}
} else {
if ($action == '5dd205015951f9f81e5b95c86457130a') {
$username = $chatApp->escapeString($_POST['username']);
$message = $chatApp->escapeString($_POST['message']);
$datetime = date('Y-m-d H:i:s');
$chatApp->setQuery("INSERT INTO logs (Username, Date_Time_Added, Message, Type) VALUES ('{$username}', '{$datetime}', '{$message}', 'Chat')");
if ($chatApp->getMessagesCount() == 1) {
echo true;
} else {
示例5: foreach
</div>
</div>
<?php
} else {
?>
<div class="chatContainer">
<div class="chatHeader">
<h3>Welcome, <?php
echo $_SESSION['username'];
?>
</h3>
<a href="logout.php" class="btn btn-custom btn-info">Logout</a>
</div>
<div class="chatMessage" id="chatMessage">
<?php
foreach ($oChat->getMessages() as $v) {
?>
<p class="cm"><b><?php
echo $v['Username'];
?>
</b>says:<br><?php
echo $v['Message'];
?>
</p>
<?php
}
?>
</div>
<div class="chatBottom">
<textarea class="addMessage" id="addMessage" placeholder="Type your message"></textarea>
</div>
示例6: Chat
<?php
include './classes/chat.php';
$oChat = new Chat();
$aMessages = $oChat->getMessages();
foreach ($aMessages as $v) {
?>
<p class="cm"><b><?php
echo $v['Username'];
?>
</b>says:<br><?php
echo $v['Message'];
?>
</p>
<?php
}