<?PHP if (file_exists("./../".$SYSD."/check-spacedata-a.inc.php")){}else{copy("./../".$SYSI."/".$SYSD."/check-spacedata-a.inc.php" , "./../".$SYSD."/check-spacedata-a.inc.php");}

$saveCheck="./../".$SYSD."/check-spacedata-a.inc.php";
include("./../function/autoX-loadingS.inc.php");

$checkZ="check-spacedata.inc.php";
include("./../function/datacheck_copy.inc.php");

include("./../function/timestamp.inc.php");
$spacedatachecktimeT=$timestamp;
$spacedatachecktimeD=$timestampZ;

$spaceAllPercent=0;
$spaceFullPercent=0;
$spaceFreePercent=0;
$spaceCheckX="txt-black4";
include("./../".$SYSD."/check-spacedata-a.inc.php");

$du=0;
$spaceUsed ="";
$checkdokumentroot=$_SERVER['DOCUMENT_ROOT'];
$spacePath=$checkdokumentroot;
exec("du -s $spacePath", $du);
//@$spaceUsed = split(" ", $du[0]); // < Php7
@$spaceUsed = preg_split('/ /', $du[0]);
@$spaceUsed = $spaceUsed[0] / 1024;
$spaceUsed = round($spaceUsed,2);
$spaceFull=$spaceUsed;
//$spaceFull=str_replace(".",",",$spaceUsed);

// ******** TEST ********
if($spacedataTest == 1){$spaceFull=$spaceFull+$spaceFull2;}
// ************************

if($spaceAll == 0 or $spaceFull == 0){
$spaceFull=0;
$spaceFree=0;
$spaceAllPercent=0;
$spaceFullPercent=0;
$spaceFreePercent=0;
$spaceFullX=0;
$spaceFreeX=0;
$spaceCheck="-";
$spaceCheckX="txt-black4";
$spaceCheckZ=$spaceCheck;
}else{
$spaceAllPercent=100;
$spaceFree=$spaceAll - $spaceFull;
$spaceFreePercent=100 - (100 / $spaceAll * $spaceFull);
$spaceFullPercent=100 - $spaceFreePercent;
$spaceCheckX="txt-black4";
$spaceCheckZ=$spaceCheck." ".$spacedata04;
}

if($spaceFreePercent < 0){
$spaceFree=0;
$spaceFreePercent=0;
$spaceFullPercent=100;
}

if($spaceFree <= $spaceCheck){$spaceCheckX="bg-orange";}
elseif($spaceAll == 0){$spaceCheckX="bg-white";}
elseif($spaceFree == 0){$spaceCheckX="bg-white";}
else{$spaceCheckX="resT";}

if($spaceAll == 0){$spaceCheckX="bg-white";}
elseif($spaceFree == 0){$spaceCheckX="bg-white";}
else{$spaceCheckX=$spaceCheckX;}

if($spaceFullPercent == 100){$spaceCheckX="resF";}

if($spaceFull == "" or $spaceFull == 0){$spaceGo=0;}else{$spaceGo=1;}

$spaceAllPercentX=number_format($spaceAllPercent,1,",",".");
$spaceFullPercentX=number_format($spaceFullPercent,1,",",".");
$spaceFreePercentX=number_format($spaceFreePercent,1,",",".");
$spaceFullX=str_replace(",",".",$spaceFull);
$spaceFreeX=str_replace(",",".",$spaceFree);
$spaceFullZ=number_format($spaceFull,1,",",".");
$spaceFreeZ=number_format($spaceFree,1,",",".");

$spaceFullPercentXs=number_format($spaceFullPercent,1,".",".");
$spaceFreePercentXs=number_format($spaceFreePercent,1,".",".");

if($spaceFree <= $spaceCheck){$spacedataW=1;}else{$spacedataW=0;}
if($spaceFree == 0){$spacedataF=1;$spacedataW=0;}else{$spacedataF=0;}

if($spaceFull == 0){
$savefile="./../".$SYSD."/check-spacedata.inc.php";
$savedataX="<?PHP 
\$spacedatachecktimeD='';
\$spacedatachecktimeT='';
\$spaceAllX='0';
\$spaceFull='0';
\$spaceFullPercent='0';
\$spaceFreeZ='0';
\$spaceFree='0';
\$spaceFreePercent='0';
\$spaceCheck='-';
\$spaceGo='0';
\$spacecheckFalseF='0';
\$spacecheckFalseW='0';
?>";
$handle=fopen($savefile, "w");
fwrite($handle,$savedataX);
fclose($handle);
}else{
$savefile="./../".$SYSD."/check-spacedata.inc.php";
$savedataX="<?PHP 
\$spacedatachecktimeD='$spacedatachecktimeD';
\$spacedatachecktimeT='$spacedatachecktimeT';
\$spaceAllX='$spaceAll';
\$spaceFull='$spaceFull';
\$spaceFullPercent='$spaceFullPercentXs';
\$spaceFreeZ='$spaceFreeZ';
\$spaceFree='$spaceFree';
\$spaceFreePercent='$spaceFreePercentXs';
\$spaceCheck='$spaceCheck';
\$spaceGo='$spaceGo';
\$spacecheckFalseF='$spacedataF';
\$spacecheckFalseW='$spacedataW';
?>";
$handle=fopen($savefile, "w");
fwrite($handle,$savedataX);
fclose($handle);
}
?>

<div class="box-body">
<table class="col-md-12 table table-bordered table-condensed">
<tr class="trcolor">
<th class="font18"><?PHP echo $areaX;?></th>
<th class="font18 txtR"><?PHP echo $resultX;?></th>
</tr>

<tr class="trtrans">
<td><?PHP echo $spacedata01;?>:</td>
<td class="txtR"><a href="#" id="spaceAll" name="spaceAll" data-type="text" data-pk="1" data-name="spaceAll" data-placement="bottom" data-original-title="<?PHP echo $spacedata07;?>">
<i class="fa fa-pencil font14 padd-right15"></i><?PHP echo $spaceAll;?></a> <?PHP echo $spacedata04." (".$spaceAllPercentX."%)";?></td>
</tr>

<tr class="menu-out2">
<td><?PHP echo $spacedata02;?>:</td>
<td class="txtR"><?PHP echo $spaceFullZ." ".$spacedata04." (".$spaceFullPercentX."%)";?></td>
</tr>

<tr class="menu-out2 <?PHP echo $spaceCheckX;?>">
<td><?PHP echo $spacedata03;?>:<div class="font13"><i class="fa fa-clock-o"></i> <?PHP echo $timestampZ;?></div></td>
<td class="txtR"><?PHP echo $spaceFreeZ." ".$spacedata04." (".$spaceFreePercentX."%)";?></td>
</tr>

<tr class="menu-out2">
<td><?PHP echo $spacedata09;?>:</td>
<td class="txtR"><?PHP echo $spaceCheckZ;?></td>
</tr>
</table>

<div class="clear"></div>
<div class="ph25"></div>
<div class="clear"></div>

<?PHP 
if($spaceAll == 0){
echo "
<div class=\"clearX txtC\">
<div class=\"resF\">".$spacedata05."</div>
<div class=\"ph25\"></div>
<div class=\"clear\"></div>
</div>
";
}
else if($spaceFull == "" or $spaceFull == 0){
echo "
<div class=\"resF\">".$spacedata06."</div>
<div class=\"ph25\"></div>
<div class=\"clear\"></div>
";
}else{
?>

<div class="txtC">
<div class="chart1x wd100x">
<div class="chart1t wd100x">
<i class="fa fa-pie-chart font18 resF"></i> <?PHP echo $spacedata02;?><br>
<i class="fa fa-pie-chart font18 resT"></i> <?PHP echo $spacedata03;?>
</div>
<div class="chart1g wd100x"><canvas id="pieChart" class="chart1b"></canvas></div>
</div>
</div>

<?PHP } ?>

<div class="clear"></div>

<div class="box-footer"><?PHP echo $noguarantee1;?></div>
</div>
