47 lines
1.4 KiB
PHP
Executable File
47 lines
1.4 KiB
PHP
Executable File
<?php
|
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
require "$root/database/credentials.php";
|
|
|
|
// Connect the database
|
|
try {
|
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
|
$user,
|
|
$password,
|
|
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
));
|
|
} catch (Exception $e) {
|
|
die("Error : ".$e->getMessage());
|
|
}
|
|
|
|
$req = $db->prepare('SELECT COUNT(*) AS counter FROM `records`');
|
|
$req->execute();
|
|
if ($data = $req->fetch()) {
|
|
$record_counter = $data['counter'];
|
|
}
|
|
$req = $db->prepare('SELECT COUNT(*) AS counter FROM `authors`');
|
|
$req->execute();
|
|
|
|
if ($data = $req->fetch()) {
|
|
$user_counter = $data['counter'];
|
|
}
|
|
$req = $db->prepare('SELECT COUNT(*) AS counter FROM `taxa`');
|
|
$req->execute();
|
|
|
|
if ($data = $req->fetch()) {
|
|
$taxa_counter = $data['counter'];
|
|
}
|
|
?>
|
|
<div id="status">
|
|
<?=$record_counter?> Records Uploaded<br>
|
|
<?=$user_counter?> Users Registered<br>
|
|
<?=$taxa_counter?> Taxa Available<br>
|
|
|
|
<?php
|
|
$bytes = disk_free_space("$root/storage/records");
|
|
$total = disk_total_space("$root/storage/records");
|
|
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
|
|
$base = 1024;
|
|
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
|
|
echo sprintf('%1.2f', $bytes / pow($base,$class)).' '.$si_prefix[$class];?> of Free space <br>
|
|
<progress id="space" max="<?=$total?>" value="<?=$total-$bytes?>"> <?=$bytes?> </progress>
|
|
</div>
|