<?

/* Nulled by Wizzywig */
/***********تعريب***********/
/**          saher        **/
/**  منتديات شباب وصبايا  **/
/**   www.shababtop.com   **/
/**  saher1986@live.com   **/
/***************************/
	session_start();
	include_once ("../includes/data_core.php");
	
	// Logout
	if ($_GET['do'] == "logout") {
		unset($_SESSION['arrowchat_admin']);
	}

	// Check Admin is Logged In
	require ("includes/functions_login.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.narrowchat.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>';
				
				html += '<br />'
				+ item.description
				+ '<br /><br />';
			}
			
			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);
		}
	});
});
</script>

<?
	$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) {
 
    $tables = mysql_list_tables($database, $db);
    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 dir="rtl" class="title_bg"> 
				<div dir="rtl" class="title">ملخص</div> 
				<div dir="rtl" class="module_content">
					<b>إحصائيات الدردشة</b><br /><br />
					<table dir="rtl" cellspacing="0" cellpadding="0">
						<tr style="height: 25px;">
							<td dir="rtl" style="width: 175px;" class="row2">عدد الرسائل:</td>
							<td style="width: 175px;" class="row1"><?=number_format($num_messages[0])?></td>
							<td dir="rtl" style="width: 175px;" class="row2">الرسائل باليوم:</td>
							<td style="width: 175px;" class="row1"><?=number_format($messages_day, 2)?></td>
						</tr>
						<tr style="height: 25px;">
							<td dir="rtl" class="row2">عدد الأعضاء:</td>
							<td class="row1"><?=number_format($num_users[0])?></td>
							<td dir="rtl" class="row2">الأعضاء باليوم:</td>
							<td class="row1"><?=number_format($users_day, 2)?></td>
						</tr>
						<tr style="height: 25px;">
							<td dir="rtl" class="row2">تم تنصيب ArrowChat :</td>
							<td class="row1"><?=date('M j, Y g:i a',$install_time[0])?></td>
							<td dir="rtl" class="row2">حجم قاعدة البيانات:</td>
							<td class="row1"><?=$database_size?></td>
						</tr>
					</table>
					<br />
					أنت تستخدم <b>ArrowChat <?=ARROWCHAT_VERSION?></b><br /><br />
					<div dir="rtl"> الستايل المعتمد هو <a href="themes.php?do=managethemes" class="bluelink"><?=$theme?></a></div>
				</div>
			</div>
			
			<div class="title_bg"> 
				<div class="title">المحادثات الأخيرة</div> 
				<div class="module_content">
			<?
				$sql = "SELECT * FROM arrowchat ORDER BY id DESC LIMIT 10";
				$result = mysql_query($sql);
				if ($result && mysql_num_rows($result) > 0) {
?>
					<table cellspacing="0" cellpadding="0">
						<tr style="height: 25px;">
							<td dir="rtl" style="width: 125px;" class="row2">من</td>
							<td dir="rtl" style="width: 125px;" class="row2">إلى</td>
							<td dir="rtl" style="width: 450px;" class="row2">الرسالة</td>
						</tr>
<?
					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=<?=$from_username[1]?>"><?=$from_username[0]?></a></td>
							<td class="row1"><a href="users.php?do=logs&id=<?=$to_username[1]?>"><?=$to_username[0]?></a></td>
							<td class="row1"><?=$row['message']?></td>
						</tr>
			<?
					}
			?>
					</table>
			<?
				} else {
			?>
					<div dir="rtl">لم يقم أحد بالدردشة!</div>
			<?
				}
			?>
				</div>
			</div>
			
			<div class="title_bg"> 
				<div dir="rtl" class="title">مدونات ArrowChat التطويرية</div> 
				<div class="module_content">
					<div dir="rtl" id="rssLoading">تحديث...</div>
					<div id="rssOutput" style="line-height: 16px; display: none;"></div>
				</div>
			</div>

<? require ("includes/pages_footer.php"); ?>