<?php
/*
 **************************************************************************************************
 *    Copyright (c) 2010-2012 Just Another Video script
 *
 * 	  This file is part of Just Another Video Script.
 *    Version 1.4.3
 *    info@justanothervideoscript.com
 **************************************************************************************************
 *    Come to website for support or buying additional plugins/modules.
 *    http://justanothervideoscript.com/
 **************************************************************************************************
 *    By using this software you agree that you have read and acknowledged our End-User License
 *    Agreement available at http://justanothervideoscript.com/license and can be bound by it.
 **********************************************************************************
 */
include_once("adminfunctions.inc");



$db->query("SELECT id FROM member") ;
$memberstotal = $db->numrows() ;
$db->query("SELECT id FROM member WHERE activationkey = '0'") ;
$membersactivated = $db->numrows() ;
$db->query("SELECT id FROM member WHERE activationkey <> '0'") ;
$membersvalidation = $db->numrows() ;
$db->query("SELECT id FROM member WHERE banned = '1'") ;
$membersbanned = $db->numrows() ;


$db->query("SELECT * FROM category") ;
$numcat = $db->numrows() ;


$db->query("SELECT * FROM media") ;
$numvideostotal = $db->numrows() ;
$db->query("SELECT * FROM media WHERE status = 'true'") ;
$numvideostrue = $db->numrows() ;
$db->query("SELECT * FROM media WHERE status = 'false'") ;
$numvideosfalse = $db->numrows() ;

$db->query("SELECT * FROM media WHERE mediatype = 'embed'") ;
$numvideosembed = $db->numrows() ;
$db->query("SELECT * FROM media WHERE mediatype = 'video'") ;
$numvideosvideo = $db->numrows() ;



$db->query("SELECT * FROM media_comment") ;
$numcom = $db->numrows() ;

$db->query("SELECT allviews FROM media WHERE status = 'true'") ;
$res = $db->fetchall() ;
$numvideoall = '' ;
foreach($res as $value) {
	$numvideoall = $numvideoall + $value['allviews'] ;
}
$db->query("SELECT dayviews FROM media WHERE status = 'true'") ;
$res = $db->fetchall() ;
$numvideotoday = '' ;
foreach($res as $value) {
	$numvideotoday = $numvideotoday + $value['dayviews'] ;
}
	
$db->query("SELECT weekviews FROM media WHERE status = 'true'") ;
$res = $db->fetchall() ;
$numvideoweek = '' ;
foreach($res as $value) {
	$numvideoweek = $numvideoweek + $value['weekviews'] ;
}
$db->query("SELECT monthviews FROM media WHERE status = 'true'") ;
$res = $db->fetchall() ;
$numvideomonth = '' ;
foreach($res as $value) {
	$numvideomonth = $numvideomonth + $value['monthviews'] ;
}
$db->query("SELECT * FROM media WHERE flagged = '1'") ;
$numflag = $db->numrows() ;


$red = "<img src='./images/red.png' border=0>" ;
$green = "<img src='./images/green.png' border=0>" ;


$ffmpegpath = getSetting(ffmpegpath, $db) ;
$curlpath = getSetting(curlpath, $db) ;
$flvtool2path = getSetting(flvtool2path, $db) ;
$mp4box = getSetting(mp4box, $db) ;


if (file_exists($ffmpegpath)) {
	$ffmpegfail = $green ;
	$ffmpegpath = $ffmpegpath;
} else {
	$ffmpegfail = $red;
	$ffmpegpath = 'FFmpeg not found...Set correct path in settings';
}
if (file_exists($curlpath)) {
	$curlfail = $green ;
	$curlpath = $curlpath;
} else {
	$curlfail = $red;
	$curlpath = 'Curl not found...Set correct path in settings';
}
if (file_exists($flvtool2path)) {
	$flvtool2fail = $green ;
	$flvtool2path = $flvtool2path;
} else {
	$flvtool2fail = $red;
	$flvtool2path = 'flvtool2 not found...Set correct path in settings';
}
if (file_exists($mp4box)) {
	$MP4Boxfail = $green ;
	$MP4Boxpath = $mp4box;
} else {
	$MP4Boxfail = $red;
	$MP4Boxpath = 'MP4Box not found...Set correct path in settings';
}

if (is_writable($rootpath.'uploads/')) {
	$Fw_uploads = $green ;
} else {
	$Fw_uploads = $red;
}
if (is_writable($rootpath.'uploads/ads')) {
	$Fw_uploads_ads = $green ;
} else {
	$Fw_uploads_ads = $red;
}
if (is_writable($rootpath.'uploads/avatars')) {
	$Fw_uploads_avatars = $green ;
} else {
	$Fw_uploads_avatars = $red;
}
if (is_writable($rootpath.'uploads/category')) {
	$Fw_uploads_category = $green ;
} else {
	$Fw_uploads_category = $red;
}
if (is_writable($rootpath.'uploads/encode')) {
	$Fw_uploads_encode = $green ;
} else {
	$Fw_uploads_encode= $red;
}
if (is_writable($rootpath.'uploads/encodelogs')) {
	$Fw_uploads_encodelogs = $green ;
} else {
	$Fw_uploads_encodelogs= $red;
}
if (is_writable($rootpath.'uploads/import')) {
	$Fw_uploads_import = $green ;
} else {
	$Fw_uploads_import= $red;
}

if (is_writable($rootpath.'uploads/newuploads')) {
	$Fw_uploads_newuploads = $green ;
} else {
	$Fw_uploads_newuploads= $red;
}
if (is_writable($rootpath.'uploads/thumbs')) {
	$Fw_uploads_thumbs = $green ;
} else {
	$Fw_uploads_thumbs= $red;
}
if (is_writable($rootpath.'uploads/vids')) {
	$Fw_uploads_vids = $green ;
} else {
	$Fw_uploads_vids= $red;
}
if (is_writable($rootpath.'sitemap')) {
	$Fw_uploads_sitemap = $green ;
} else {
	$Fw_uploads_sitemap = $red;
}	


if (is_writable($rootpath.'includes/settings.inc')) {
	$Fw_uploads_incl_set = $green ;
} else {
	$Fw_uploads_incl_set = $red;
}
if (is_writable('modules/settings.inc')) {
	$Fw_uploads_incl_adm = $green ;
} else {
	$Fw_uploads_incl_adm = $red;
}



$df = disk_free_space($rootpath);
$dt = disk_total_space($rootpath);
$du = $dt - $df;
$dp = sprintf('%.2f',($du / $dt) * 100);
$df = formatSize($df);
$du = formatSize($du);
$dt = formatSize($dt);


?>
<style type='text/css'>
    .serverinfo {
            border: 2px solid #000000;
            height: 32px;
            width: 300px;
            margin: 30px auto;
    }
    .serverinfo .prgbar {
	    background: none repeat scroll 0 0 #A7C6FF;
	    height: 32px;
	    margin-top: -25px;
            width: <?php echo $dp; ?>%;
	    z-index: 999;
    }
    .serverinfo .prgtext {
            color: #286692;
            text-align: center;
            font-size: 13px;
            padding: 9px 0 0;
            width: 300px;
            z-index: 1000;
    }
    .serverinfo .prginfo {
            margin: 3px 0;
    }
</style>

<h2>Server Info</h2>
<h4>Check for new version of JAVS? go to <a href="http://www.justanothervideoscript.com/download">www.justanothervideoscript.com/download</a></h4>
<h4>Your Current Version is 1.4.3</h4>
<div id="status">	
	
	<div class="statusfirst">
	<fieldset>
		<table>
			<p class="statustop">Total Disk Space</p>
			<tr>
			<td>
			<div class='serverinfo'>
				<div class='prgtext'><?php echo $dp; ?>% Disk Used</div>
				<div class='prgbar'></div>
				<div class='prginfo'>
					<span><?php echo "$du used of $dt total"; ?></span>
				</div>
			</div>
			</td>
			</tr>
		</table>
	</fieldset>
	<fieldset>
		<table>
			<p class="statustop">Site overview</p>
			<tr>
				<td>Number of categories:</td>
				<td><?=$numcat?></td>
			</tr>
			<tr>
				<td>Number of comments:</td>
				<td><?=$numcom?></td>
			</tr>
			<tr>
				<td>Video number all time:</td>
				<td><?=$numvideoall?></td>
			</tr>	
			<tr>
				<td>Video number viewed today:</td>
				<td><?=$numvideotoday?></td>
			</tr>	
			<tr>
				<td>Video number viewed this week:</td>
				<td><?=$numvideoweek?></td>
			</tr>
			<tr>
				<td>Video number viewed this month:</td>
				<td><?=$numvideomonth?></td>
			</tr>	
		</table>
	</fieldset>
	<fieldset>
		<table>
			<p class="statustop">Video Statistics</p>
			<tr>
				<td>Approved videos:</td>
				<td><?=$numvideostrue?></td>
			</tr>
			<tr>
				<td>Unapproved videos:</td>
				<td><?=$numvideosfalse?></td>
			</tr>
			<tr>
				<td>Embedded videos:</td>
				<td><?=$numvideosembed?></td>
			</tr>			
			<tr>
				<td>Real videos:</td>
				<td><?=$numvideosvideo?></td>
			</tr>			
			<tr>
				<td>Flagged videos:</td>
				<td><?=$numflag?></td>
			</tr>
			<tr>
				<td>Total number of videos:</td>
				<td><?=$numvideostotal?></td>
			</tr>			
			
			
		</table>
	</fieldset>	
	
	
	
	<fieldset>
		<table>
			<p class="statustop">Member Statistics</p>
			<tr>
				<td>Members Activated:</td>
				<td><?=$membersactivated?></td>
			</tr>
			<tr>
				<td>Members Awaiting Validation:</td>
				<td><?=$membersvalidation?></td>
			</tr>				
			<tr>
				<td>Members Banned:</td>
				<td><?=$membersbanned?></td>
			</tr>				
			<tr>
				<td>Total Members:</td>
				<td><?=$memberstotal?></td>
			</tr>	
		</table>
	</fieldset>
	</div>
	<div class="statusfirst">
	<fieldset>
		<table>	
			<p class="statustop">Chmod Settings</p>
			<tr>
				<td>Folder /Uploads/:</td>
				<td><?=$Fw_uploads?></td>
			</tr>	
			<tr>
				<td>Folder /Uploads/ads/:</td>
				<td><?=$Fw_uploads_ads?></td>
			</tr>	
			<tr>
				<td>Folder /Uploads/avatars/:</td>
				<td><?=$Fw_uploads_avatars?></td>
			</tr>			
			<tr>
				<td>Folder /Uploads/category/:</td>
				<td><?=$Fw_uploads_category?></td>
			</tr>			
			<tr>
				<td>Folder /Uploads/encode/:</td>
				<td><?=$Fw_uploads_encode?></td>
			</tr>			
			<tr>
				<td>Folder /Uploads/encodelogs/:</td>
				<td><?=$Fw_uploads_encodelogs?></td>
			</tr>						
			<tr>
				<td>Folder /Uploads/import/:</td>
				<td><?=$Fw_uploads_import?></td>
			</tr>	
			<tr>
				<td>Folder /Uploads/newuploads/:</td>
				<td><?=$Fw_uploads_newuploads?></td>
			</tr>		
			<tr>
				<td>Folder /Uploads/thumbs/:</td>
				<td><?=$Fw_uploads_thumbs?></td>
			</tr>		
			<tr>
				<td>Folder /Uploads/vids/:</td>
				<td><?=$Fw_uploads_vids?></td>
			</tr>	
			<tr>
				<td>Folder /Uploads/vids/:</td>
				<td><?=$Fw_uploads_vids?></td>
			</tr>			
			<tr>
				<td>Folder /sitemap/:</td>
				<td><?=$Fw_uploads_sitemap?></td>
			</tr>	
			<tr>
				<td>File includes/settings.inc':</td>
				<td><?=$Fw_uploads_incl_set?></td>
			</tr>			
			<tr>
				<td>Folder /modules/settings.inc:</td>
				<td><?=$Fw_uploads_incl_adm?></td>
			</tr>		
		</table>
	</fieldset>
		
	<fieldset>
		<table>
			<p class="statustop">Encoding program paths</p>
			<tr>
				<td>FFmpeg:</td>
				<td><?=$ffmpegpath?></td>
				<td><?=$ffmpegfail?></td>
			</tr>	
			<tr>
				<td>flvtool2:</td>
				<td><?=$flvtool2path?></td>
				<td><?=$flvtool2fail?></td>
			</tr>			
			<tr>
				<td>Curl:</td>
				<td><?=$curlpath?></td>
				<td><?=$curlfail?></td>
			</tr>			
			<tr>
				<td>MP4Box:</td>
				<td><?=$MP4Boxpath?></td>
				<td><?=$MP4Boxfail?></td>
			</tr>	
		</table>
	</fieldset>	
	</div>
	
</div>
