Viewing File: /usr/local/cpanel/base/frontend/jupiter/inode_counter/rin.live.php
#!/usr/bin/php-cgi
<?php
include("/usr/local/cpanel/php/cpanel.php");
global $cpanel;
$cpanel = new CPANEL();
$user_cpuser = getenv('REMOTE_USER');
$curr_theme = $get_theme_base = $cpanel->uapi('Themes', 'get_theme_base');
function SetStdHeader($theme)
{
// create default header
global $cpanel;
return $cpanel->header("Inodes usage");
}
function SetStdFooter($theme)
{
// create default footer
global $cpanel;
return $cpanel->footer();
}
function remvspc($line)
{
// replace multiple spaces with single space
$res = preg_replace('!\s+!', ' ', $line);
return $res;
}
function remvspcR($line)
{
// replace multiple spaces with single space
$res = preg_replace('!\s+!', ' ', $line);
$res = explode(' ', $line, 2);
$res2 = explode(':', $res['1'], 2);
$res3 = explode(' ', $res['1'], 4);
$result['0'] = $res3[2];
$result['1'] = $res3[0];
return $result;
}
function custom_sort($a, $b)
{
return $a['0'] < $b['0'];
}
// sort array
print (SetStdHeader($curr_theme["cpanelresult"]["result"]["data"]));
// print header
// -----------------------------Adjust-Home-Button-Link------------------------------------------------------------------------#
print ('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>');
print ('
<script type="text/javascript">
var baseUrl = window.location.href;
baseUrl = baseUrl.replace("frontend/jupiter/rin.live.php", "");
$("#lnkQuickHome").prop("href", baseUrl);
$(".spriteheading_img a").prop("href", baseUrl);
</script>
');
print ('<script type="text/javascript">$("#heading-help_off").css("display", "none");</script>');
print ('<style>td {padding:5px;} </style>');
print ('
<style>
body {
text-align:center;
}
.input-button {
width:280px
}
</style>
<script type="text/javascript">
$(function() {
$("#belka")
.click(function( event ) {
event.preventDefault();
$("#belka").on("click", switch_display("#tables", "#belka"));
});
});
$(function() {
$("#sasa")
.click(function( event ) {
event.preventDefault();
$("#sasa").on("click", switch_display("#tabled", "#sasa"));
});
});
function switch_display(el, button) {
var elem = $(el);
var but = $(button);
if (elem.css("display") == "none") {
elem.css("display", "block");
but.prop("value","Click here to hide stats");
} else {
elem.css("display", "none");
but.prop("value", "Click here to expand stats");
}
}
</script>
');
// ----------------------------LOG-FILES-LOCATION---------------------------------------------------------------------------------------#
$cpacc = '/home/' . $user_cpuser . '/.last.inodes';
$reseller = '/home/' . $user_cpuser . '/.last_reseller.inodes';
?>
<?php
if (file_exists($cpacc))
{
$linesa = file($cpacc, FILE_IGNORE_NEW_LINES);
// Import report to single array.
$linesa = array_map("remvspc", $linesa);
// Transform multiple spaces into single space
// Importing User and inodes number into 2-dimensional array
// lines_er(
// array[1]=>
// [1]=>Folder
// [2]=>Inodes number
// array[2]=>....
echo "<div>";
$sizea = count($linesa);
$lastMODa = $linesa[$sizea - 1];
array_pop($linesa);
for ($i = 0; $i < count($linesa); ++$i)
{
$lines_er[$i] = explode(" ", $linesa[$i], 2);
$lines_er[$i][1] = substr($lines_er[$i][1], 1);
};
usort($lines_er, "custom_sort");
echo "<center><p style=\"font-size: 22px\"> cPanel account inodes usage statistics </p> </center>";
print('<input type="submit" value="Click here to expand list" id="belka">');
print('<div id="tables" style="display:none;"> <br>');
echo "<table border='1' cellpadding='3' cellspacing='0' style='clear:both; table-layout:fixed; width:95%' align='center'>";
// Outputing the results
echo "<tr style='background-color: #a4a6a6;' >";
echo "<td align='left' style=''>";
echo "<strong>Folder</strong>";
echo "</td>";
echo "<td align='left' id='rowx' style='width:10%' >";
echo "<strong>Inodes number</strong>";
echo "</td>";
echo "</tr>";
for ($y = 0; $y <= count($linesa) - 1; $y++)
{
echo "<tr width:600px >";
echo "<td align='left' style='word-wrap:break-word;' width:200px >";
// Formatting file manager link address
$folder_full_path = $lines_er[$y][1];
$user_home_dir = "home/" . $user_cpuser;
$folder_relative_path = str_replace($user_home_dir, "", $folder_full_path);
echo '<a href="../filemanager/index.html?dirselect=homedir&dir=' . $folder_relative_path . '" target="_blank"><b>' . $folder_full_path . '</b></a>';
// Folder name output
echo "</td>";
echo "<td align='left' width:350px >";
echo $lines_er[$y][0];
// Inodes number output
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br><center> $lastMODa </center>";
echo "</div>";
echo "</div>";
}
else
{
echo "<br /> <center> cPanel account inodes statistics is not yet ready for your account. Kindly wait for up to 24 hours</center> <br />";
}
?>
<?php
// >>---------------------------------Reseller--Stats-----------------------------------<<\\
$isReseller = $cpanel->cpanelprint('$isreseller');
if ($isReseller == '1')
{ echo "<br>";
echo "<center><p style=\"font-size: 22px\"> Resold accounts inodes usage statistics </p></center>";
if (file_exists($reseller))
{
$lines = file($reseller, FILE_IGNORE_NEW_LINES);
// Import report to single array.
$lines = array_map("remvspc", $lines);
// Transform multiple spaces into single space
// Importing User and inodes number into 2-dimensiona l array
// lines_e(
// array[1]=>
// [1]=>User
// [2]=>Inodes number
// array[2]=>....
print('<input type="submit" value="Click here to expand list" id="sasa">');
print('<div id="tabled" style="display:none"><br>');
$size = count($lines);
$lastMOD = "Last modified: " . date("D M j G:i:s T Y", filemtime($reseller));
// array_pop($lines);
for ($i = 0; $i < count($lines); ++$i)
{
$lines_e[$i] = remvspcR($lines[$i]);
};
usort($lines_e, "custom_sort");
echo "<table border='1' cellpadding='2' cellspacing='0' style='clear:both' width='45%' align='center'>";
// Outputing the results
echo "<tr style='background-color: #a4a6a6;' >";
echo "<td align='left' >";
echo "<strong>User</strong>";
echo "</td>";
echo "<td align='left' width=30% id='rowx'>";
echo "<strong>Inodes number</strong>";
echo "</td>";
echo "</tr>";
for ($y = 0; $y <= count($lines) - 1; $y++)
{
echo "<td align='left' >";
echo $lines_e[$y]['1'];
// User ID output
echo "</td>";
echo "<td align='left' id='row$y'>";
echo $lines_e[$y]['0'];
// Inodes number output
echo "</td>";
echo "</tr>";
}
echo "<tr style='background-color: ;' >";
echo "<td align='left' >";
echo "<strong>Total usage</strong>";
echo "</td>";
echo "<td align='left' id='rowx'>";
$total = 0;
foreach($lines_e as $values)
{
$total+= $values[0];
}
echo "<strong>" . $total . "</strong>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br />";
echo "<center> $lastMOD </center>";
echo "</div>";
}
else
{
echo "<br /><center> Resold accounts inodes statistics is not yet ready for your account. Kindly wait for up to 24 hours</center> <br />";
}
}
?>
<?php
echo "<div>";
print (SetStdFooter($curr_theme["cpanelresult"]["result"]["data"]));
print ('<script type="text/javascript">var baseUrl = window.location.href;baseUrl = baseUrl.replace("frontend/jupiter/rin.live.php",
"");$("#lnkQuickHome").prop("href",
baseUrl);$("#lnkFooterHome").prop("href", baseUrl); </script>');
$cpanel->end();
echo "</div>";
?>
Back to Directory
File Manager