by smitchell 09 Apr 2012, 00:24
Sorry where do i add it and what do i add pls????? :)
session_start();
include_once ("../includes/data_core.php");
// Logout
if (@$_GET['do'] == "logout") {
unset($_SESSION['arrowchat_admin_'.$_SERVER['SERVER_NAME']]);
unset($_SESSION['arrowchat_admin']);
setcookie('arrowchat_admin', '', time()-3600);
header("Location: ./");
}
// Check Admin is Logged In
require ("includes/functions_login.php");
// Clear Chat History
if (@$_GET['do'] == "delete_history") {
$sql = ("DELETE FROM arrowchat
WHERE arrowchat.read = 1
AND ('".time()."'-arrowchat.sent) > 10800"); // Deletes 3 hours old
mysql_query($sql);
$sql = ("DELETE FROM arrowchat_notifications
WHERE arrowchat_notifications.user_read = 1
AND ('".time()."' - arrowchat_notifications.alert_time) > 432000"); // Deletes 5 days old
mysql_query($sql);
}
// Convert numeric themes
if (is_numeric($theme)) {
$sql = "SELECT folder FROM arrowchat_themes WHERE id='".$theme."'";
$result = mysql_query($sql);
if ($result && mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
$theme = $row['folder'];
} else {
$theme = "new_facebook";
}
}
?>
<?php require ("includes/pages_header.php"); ?>
<script type="text/javascript" src="includes/js/jquery.jfeed.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
jQuery.getFeed({
url: 'proxy_rss.php?url=http://www.arrowchat.com/blog/wp-rss2.php',
success: function(feed) {
var html = '';
for(var i = 0; i < feed.items.length && i < 5; i++) {
var item = feed.items[i];
var date = item.updated.split(" ");
html += '<span style="font-size:13px;"><a target="_blank" class="bluelink" href="'
+ item.link
+ '">'
+ item.title
+ '</a></span>';
html += '<div style="display: inline; margin-left: 5px; color: #666666;">'
+ date[2] + ' ' + date[1] + ', ' + date[3]
+ '</div>';
var test = false;
var matches = item.description.match(/img/gi);
if (matches != null) {
test = true;
}
item.description = item.description.replace('<img','<img style="display: none;"');
item.description = item.description.replace('<span style="color: #585858; font-family: arial; font-size:13px; font-weight: bold;">', '<span style="color: #585858; font-family: arial; font-size:13px; font-weight: bold; display: none;">');
if (test) {
html += '<div style="line-height: 1.4em; margin-top: -30px; margin-bottom: 30px;">'
+ item.description
+ '</div>';
} else {
html += '<div style="line-height: 1.4em; margin-top: 10px; margin-bottom: 30px;">'
+ item.description
+ '</div>';
}
}
html = html.substr(0,html.length-6);
$('#rssLoading').hide();
$('#rssOutput').fadeIn("normal");
$('#rssOutput').html(html);
},
error: function(x,e) {
var html = 'There was an error loading the blog. Please try refershing.';
$('#rssLoading').hide();
$('#rssOutput').fadeIn("normal");
$('#rssOutput').html(html);
}
});
});
function confirmSubmit()
{
var agree=confirm("Are you sure you want to delete messages older than 3 hours and notifications older than 5 days?");
if (agree)
return true ;
else
return false ;
}
</script>
<?php
$sql = "SELECT COUNT(*) FROM arrowchat";
$result = mysql_query($sql);
$num_messages = mysql_fetch_row($result);
$sql = "SELECT COUNT(*) FROM ".TABLE_PREFIX.DB_USERTABLE;
$result = mysql_query($sql);
$num_users = mysql_fetch_row($result);
$sql = "SELECT config_value FROM arrowchat_config WHERE config_name='install_time'";
$result = mysql_query($sql);
$install_time = mysql_fetch_row($result);
$days_since = (time() - $install_time[0]) / 86400;
$messages_day = $num_messages[0] / $days_since;
$users_day = $num_users[0] / $days_since;
$database_size = CalcFullDatabaseSize(DB_NAME, $dbh);
function CalcFullDatabaseSize($database, $db) {
$sql = "SHOW TABLES FROM " . $database;
$tables = mysql_query($sql);
if (!$tables) { return -1; }
$table_count = mysql_num_rows($tables);
$size = 0;
for ($i=0; $i < $table_count; $i++) {
$tname = mysql_tablename($tables, $i);
$r = mysql_query("SHOW TABLE STATUS FROM ".$database." LIKE '".$tname."'");
$data = mysql_fetch_array($r);
$size += ($data['Index_length'] + $data['Data_length']);
};
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
for ($i = 0; $size > 1024; $i++) { $size /= 1024; }
return round($size, 2).$units[$i];
}
?>
<div class="title_bg">
<div class="title">Overview</div>
<div class="module_content">
<b>Chat Statistics</b><br /><br />
<table cellspacing="0" cellpadding="0">
<tr style="height: 25px;">
<td style="width: 175px;" class="row1"><div style="margin-bottom: 5px;">Number of messages:<br /><a href="./index.php?do=delete_history" onClick="return confirmSubmit()">Delete Chat History</a></div></td>
<td style="width: 175px;" class="row2" valign="top"><?php echo number_format($num_messages[0]); ?> <?php if ($num_messages[0]>10000) { ?><img src="images/warning.png" border="0" title="Your database is getting full. It is recommended that you delete your chat history immediately." /><?php } ?></td>
<td style="width: 175px;" class="row1" valign="top">Messages per day:</td>
<td style="width: 175px;" class="row2" valign="top"><?php echo number_format($messages_day, 2); ?></td>
</tr>
<tr style="height: 25px;">
<td class="row1">Number of users:</td>
<td class="row2"><?php echo number_format($num_users[0]); ?></td>
<td class="row1">Users per day:</td>
<td class="row2"><?php echo number_format($users_day, 2); ?></td>
</tr>
<tr style="height: 25px;">
<td class="row1">ArrowChat Installed:</td>
<td class="row2"><?php echo date('M j, Y g:i a',$install_time[0]); ?></td>
<td class="row1">Database size:</td>
<td class="row2"><?php echo $database_size; ?></td>
</tr>
</table>
<br />
You are using <b>ArrowChat <?php echo ARROWCHAT_VERSION; ?></b><br /><br />
Default theme is <a href="themes.php?do=managethemes" class="bluelink"><?php echo $theme; ?></a>
</div>
</div>
<div class="title_bg">
<div class="title">Recent Chat</div>
<div class="module_content">
<?php
$query = "SELECT COUNT(id) AS numrows FROM arrowchat";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$pagenum = 1;
$self = $_SERVER['PHP_SELF'];
$nav = 'Page ';
$maxpage = 10;
$total_pages = ceil($numrows / $maxpage);
if(isset($_GET['page'])) {
$pagenum = $_GET['page'];
}
for ($i=1; $i<=$total_pages; $i++) {
if ($i == $pagenum) {
$nav .= " $i ";
} else if ($i <= 5) {
$nav .= " <a href=\"$self?page=$i\">".floor($i)."</a> ";
}
}
$offset = ($pagenum - 1) * $maxpage;
$sql = " SELECT * FROM arrowchat ORDER BY id DESC LIMIT $offset, $maxpage";
$result = mysql_query($sql);
if ($result && mysql_num_rows($result) > 0) {
?>
<table cellspacing="0" cellpadding="0">
<tr style="height: 25px;">
<td style="width: 125px;" class="row2">From</td>
<td style="width: 125px;" class="row2">To</td>
<td style="width: 305px;" class="row2">Message</td>
<td style="width: 50px;" class="row2">Read</td>
<td style="width: 125px;" class="row2">Sent</td>
</tr>
<?php
while ($row = mysql_fetch_array($result)) {
$sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row['from']."'";
$result2 = mysql_query($sql);
$from_username = mysql_fetch_row($result2);
$sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row['to']."'";
$result2 = mysql_query($sql);
$to_username = mysql_fetch_row($result2);
?>
<tr style="height: 25px;">
<td class="row1"><a href="users.php?do=logs&id=<?php echo $from_username[1]; ?>"><?php echo $from_username[0]; ?></a></td>
<td class="row1"><a href="users.php?do=logs&id=<?php echo $to_username[1]; ?>"><?php echo $to_username[0]; ?></a></td>
<td class="row1"><div style="overflow: hidden; width: 300px;"><?php echo $row['message']; ?></div></td>
<?php
if($row['user_read'] == 1) {
echo '<td class="row1">Yes</td>';
} else {
echo '<td class="row1">No</td>';
}
?>
<td class="row1"><?php echo date("M j, Y",$row['sent']); ?><br><?php echo date("g:i a",$row['sent']); ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5">
<div style="margin-top: 10px; float: left;">
<?php echo $nav; ?>
</div>
</td>
</tr>
</table>
<?php
} else {
?>
No one has ever chatted!
<?php
}
?>
</div>
</div>
<div class="title_bg">
<div class="title">ArrowChat Development Blog</div>
<div class="module_content">
<div id="rssLoading">Loading...</div>
<div id="rssOutput" style="line-height: 16px; display: none;"></div>
</div>
</div>
<?php require ("includes/pages_footer.php"); ?>