-
RevCMS Help
My housekeeping on RevCMS, it was based to work on r63 GTE but I changed to azure and been editing it to work with the azure structure and the only thing I have an issue with is the chatlogs when searching for chatlogs based by username because the azure structure for chatlogs has the users id and not username so could anyone help me with this?
The code for my chatlogs is below
PHP Code:
<?php
$searchResults = null;
if (isset($_GET['timeSearch']))
{
$_POST['searchQuery'] = $_GET['timeSearch'];
$_POST['searchType'] = '4';
}
if (isset($_POST['searchQuery']))
{
$query = filter($_POST['searchQuery']);
$type = $_POST['searchType'];
$q = "SELECT * FROM users_chatlogs WHERE ";
switch ($type)
{
default:
case '1':
$q .= "user_id = '" . $query . "'";
break;
case '2':
$q .= "message LIKE '%" . $query . "%'";
break;
case '3':
$q .= "room_id = '" . $query . "'";
break;
case '4':
$cutMin = intval($query) - 300;
$cutMax = intval($query) + 300;
$q .= "timestamp >= " . $cutMin . " AND timestamp <= " . $cutMax;
}
$searchResults = mysql_query($q);
}
?>
<?php
if (isset($searchResults))
{
echo '<h2>Show
Results: - You have Searched for "<span style="font-size: 125%;">' . filter($_POST['searchQuery']) . '</span>"</h2>';
echo '<br /><p><a href="chatlogs" class="btn btn-small btn-primary">Back to Search</a></p><br />
<table class="table table-striped">
<thead>
<tr>
<th>User</th>
<th>Room</th>
<th>Message</th>
<th>Timestamp</th>
</tr>
</thead>
<tbody> ';
while ($result = mysql_fetch_assoc($searchResults))
{
$grabRoom2 = mysql_query("SELECT * FROM rooms_data WHERE id = '" . $result['room_id'] . "'");
while ($room2 = mysql_fetch_assoc($grabRoom2))
{
$grabUser2 = mysql_query("SELECT * FROM users WHERE id = '" . $result['user_id'] . "'");
while ($user2 = mysql_fetch_assoc($grabUser2))
{
echo '<tr">';
// Username of sender
echo '<td align="left" valign="top">' . $user2['username'] . '</td>';
// Room ID
echo '<td align="left" valign="top">' . $room2['caption'] . '</td>';
// Message
echo '<td align="left" valign="top">' . htmlspecialchars($result['message']) . '</td>';
// Timestamp (UNIX Timestamp)
echo '<td align="left" valign="top">' . date('m.d.y, g:i a', $result['timestamp']) . '</td>';
echo '</tr>';
echo '</tbody>
</thead>
</table>';
}
}
}
?>
<?php } else { ?>
<?php
echo '<h2>Search Chatlogs</h2>
<br />
<form method="post">
Search Type:
<select name="searchType">
<option value="1">By User</option>
<option value="2">By message content</option>
<option value="3">By Room (Single ID)</option>
<option value="4">By timestamp (600 seconds range)</option>
</select>
<br /><br />
Search:
<input type="text" name="searchQuery">
<br />
<input type="submit" class="btn btn-small btn-primary" value="Search Records">
</form>
</br><h2>Recent Activity</h2>
<table class="table table-striped">
<thead>
<tr>
<th>User</th>
<th>Room</th>
<th>Message</th>
<th>Timestamp</th>
</tr>
</thead>
<tbody> ';
$getWhisper = mysql_query("SELECT * FROM users_chatlogs ORDER BY id DESC LIMIT 30");
while ($whisper = mysql_fetch_assoc($getWhisper))
{
$getWhisper2 = mysql_query("SELECT * FROM users WHERE id = '" . $whisper['user_id'] . "'");
while ($whisper2 = mysql_fetch_assoc($getWhisper2))
{
$grabRoom = mysql_query("SELECT * FROM rooms_data WHERE id = '" . $whisper['room_id'] . "'");
while ($room = mysql_fetch_assoc($grabRoom))
{
echo '<tr">';
// Username of sender
echo '<td align="left" valign="top">' . $whisper2['username'] . '</td>';
// Room ID
echo '<td align="left" valign="top">' . $room['caption'] . '</td>';
// Message
echo '<td align="left" valign="top">' . htmlspecialchars($whisper['message']) . '</td>';
// Timestamp (UNIX Timestamp)
echo '<td align="left" valign="top">' . date('m.d.y, g:i a', $whisper['timestamp']) . '</td>';
echo '</tr>';
}
}
}
}
?>