static function ListBackUps($userid) { $currentuser = ctrl_users::GetUserDetail($userid); $userid = $currentuser['userid']; $username = $currentuser['username']; $res = array(); $dirFiles = array(); $backupdir = ctrl_options::GetSystemOption('hosted_dir') . $username . "/backups/"; if ($handle = opendir($backupdir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && stristr($file, "_") && substr($file, -4) == ".zip") { $dirFiles[] = $file; } } } closedir($handle); if (!fs_director::CheckForEmptyValue($dirFiles)) { sort($dirFiles); foreach ($dirFiles as $file) { $filesize = fs_director::ShowHumanFileSize(filesize($backupdir . $file)); $filedate = date("F d Y H:i:s", filemtime($backupdir . $file)); array_push($res, array('backupfile' => substr($file, 0, -4), 'created' => $filedate, 'filesize' => $filesize)); } } self::array_sort_by_column($res, 'created'); return $res; }
public static function Template() { $currentuser = ctrl_users::GetUserDetail(); if ($currentuser['bandwidthquota'] == 0) { $bandwidthquota = '<: Unlimited :>'; } else { $bandwidthquota = fs_director::ShowHumanFileSize($currentuser['bandwidthquota']); } return $bandwidthquota; }
static function ListCurrentDatabases($mysqlid) { global $zdbh; $sql = "SELECT * FROM x_mysql_databases WHERE my_id_pk=:mysqlid AND my_deleted_ts IS NULL"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':mysqlid', $mysqlid); $numrows->execute(); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); $sql->bindParam(':mysqlid', $mysqlid); $res = array(); $sql->execute(); while ($rowmysql = $sql->fetch()) { $res[] = array('mysqlid' => $rowmysql['my_id_pk'], 'mysqlname' => $rowmysql['my_name_vc'], 'mysqlsize' => $rowmysql['my_usedspace_bi'], 'mysqlfriendlysize' => fs_director::ShowHumanFileSize($rowmysql['my_usedspace_bi'])); } return $res; } else { return false; } }
static function getShadowAccounts() { global $zdbh; global $controller; $currentuser = ctrl_users::GetUserDetail(); if ($currentuser['username'] == 'zadmin') { $sql = "SELECT * FROM x_accounts WHERE ac_deleted_ts IS NULL ORDER BY ac_user_vc"; $numrows = $zdbh->prepare($sql); $numrows->execute(); } else { $sql = "SELECT * FROM x_accounts WHERE ac_reseller_fk = :userid AND ac_deleted_ts IS NULL ORDER BY ac_user_vc"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':userid', $currentuser['userid']); $numrows->execute(); } //$numrows = $zdbh->query($sql); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); if ($currentuser['username'] == 'zadmin') { //noi bind needed } else { //bind the username $sql->bindParam(':userid', $currentuser['userid']); } $res = array(); $sql->execute(); while ($rowclients = $sql->fetch()) { if ($rowclients['ac_id_pk'] != $currentuser['userid']) { $clientdetail = ctrl_users::GetUserDetail($rowclients['ac_id_pk']); array_push($res, array('clientusername' => $clientdetail['username'], 'clientid' => $rowclients['ac_id_pk'], 'packagename' => $clientdetail['packagename'], 'usergroup' => $clientdetail['usergroup'], 'currentdisk' => fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('diskspace', $rowclients['ac_id_pk'])), 'currentbandwidth' => fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('bandwidth', $rowclients['ac_id_pk'])))); } } return $res; } else { return false; } }
static function DisplayUsagepChart() { global $zdbh; global $controller; $currentuser = ctrl_users::GetUserDetail(); self::$diskquota = $currentuser['diskquota']; self::$diskspace = ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid']); self::$bandwidthquota = module_controller::empty_as_0($currentuser['bandwidthquota']); self::$bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid']); self::$domainsquota = module_controller::empty_as_0($currentuser['domainquota']); self::$domains = ctrl_users::GetQuotaUsages('domains', $currentuser['userid']); self::$subdomainsquota = module_controller::empty_as_0($currentuser['subdomainquota']); self::$subdomains = ctrl_users::GetQuotaUsages('subdomains', $currentuser['userid']); self::$parkeddomainsquota = module_controller::empty_as_0($currentuser['parkeddomainquota']); self::$parkeddomains = ctrl_users::GetQuotaUsages('parkeddomains', $currentuser['userid']); self::$mysqlquota = module_controller::empty_as_0($currentuser['mysqlquota']); self::$mysql = ctrl_users::GetQuotaUsages('mysql', $currentuser['userid']); self::$ftpaccountsquota = module_controller::empty_as_0($currentuser['ftpaccountsquota']); self::$ftpaccounts = ctrl_users::GetQuotaUsages('ftpaccounts', $currentuser['userid']); self::$mailboxquota = module_controller::empty_as_0($currentuser['mailboxquota']); self::$mailboxes = ctrl_users::GetQuotaUsages('mailboxes', $currentuser['userid']); self::$forwardersquota = module_controller::empty_as_0($currentuser['forwardersquota']); self::$forwarders = ctrl_users::GetQuotaUsages('forwarders', $currentuser['userid']); self::$distlistsquota = $currentuser['distlistsquota']; self::$distlists = module_controller::empty_as_0(ctrl_users::GetQuotaUsages('distlists', $currentuser['userid'])); $maximum = self::$diskquota; $used = self::$diskspace; if ($maximum == 0) { if (sys_versions::ShowOSPlatformVersion() != 'Windows') { // We'll specify the full path to the hsoted directory to ensure that NFS mounts etc are taken into account. $free = disk_free_space(ctrl_options::GetOption('hosted_dir')); } else { // On Windows we'll check the disk (partition) that is configured for the 'hostdata' directory. $free = disk_free_space(substr(ctrl_options::GetOption('hosted_dir'), 0, 2)); } $freeLabel = fs_director::ShowHumanFileSize($free) . ' (' . ui_language::translate('Server disk') . ')'; } else { $free = max($maximum - $used, 0); $freeLabel = fs_director::ShowHumanFileSize($free); } $usedLabel = fs_director::ShowHumanFileSize($used); $line = '<table class="none" cellpadding="0" cellspacing="0">' . '<tr>' . '<td align="left" valign="top" width="350px">' . '<h2>' . ui_language::translate('Disk Usage Total') . '</h2>' . '<img src="etc/lib/pChart2/MADmin/z3DPie.php?score=' . $free . '::' . $used . '&imagesize=350::250&chartsize=150::120&radius=150' . '&labels=Free_Space: ' . $freeLabel . '::Used_Space: ' . $usedLabel . '&legendfont=verdana&legendfontsize=8&legendsize=10::220"/>' . '</td>' . '<td align="left" valign="top">' . '<h2>' . ui_language::translate('Package Usage Total') . '</h2>' . '<table class="table table-striped" border="0" cellspacing="0" cellpadding="0">' . module_controller::build_row_usage('Disk space', self::$diskspace, self::$diskquota == 0 ? -1 : self::$diskquota, true) . module_controller::build_row_usage('Bandwidth', self::$bandwidth, self::$bandwidthquota == 0 ? -1 : self::$bandwidthquota, true) . module_controller::build_row_usage('Domains', self::$domains, self::$domainsquota) . module_controller::build_row_usage('Sub-domains', self::$subdomains, self::$subdomainsquota) . module_controller::build_row_usage('Parked domains', self::$parkeddomains, self::$parkeddomainsquota) . module_controller::build_row_usage('FTP accounts', self::$ftpaccounts, self::$ftpaccountsquota) . module_controller::build_row_usage('MySQL® databases', self::$mysql, self::$mysqlquota) . module_controller::build_row_usage('Mailboxes', self::$mailboxes, self::$mailboxquota) . module_controller::build_row_usage('Mail forwarders', self::$forwarders, self::$forwardersquota) . module_controller::build_row_usage('Distribution lists', self::$distlists, self::$distlistsquota) . '</table>' . '</td>' . '</tr>' . '</table>'; return $line; }
static function ListDisabledClients($uid) { global $zdbh; $sql = "SELECT * FROM x_accounts WHERE ac_reseller_fk=:uid AND ac_enabled_in=0 AND ac_deleted_ts IS NULL"; //$numrows = $zdbh->query($sql); $numrows = $zdbh->prepare($sql); $numrows->bindParam(':uid', $uid); $numrows->execute(); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); $sql->bindParam(':uid', $uid); $res = array(); $sql->execute(); while ($rowclients = $sql->fetch()) { if ($rowclients['ac_user_vc'] != "zadmin") { $currentuser = ctrl_users::GetUserDetail($rowclients['ac_id_pk']); $currentuser['diskspacereadable'] = fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid'])); $currentuser['diskspacequotareadable'] = fs_director::ShowHumanFileSize($currentuser['diskquota']); $currentuser['bandwidthreadable'] = fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid'])); $currentuser['bandwidthquotareadable'] = fs_director::ShowHumanFileSize($currentuser['bandwidthquota']); array_push($res, $currentuser); } } return $res; } else { return false; } }
public static function Template() { $currentuser = ctrl_users::GetUserDetail(); return fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid'])); }
static function getLogErrorList() { $currentuser = ctrl_users::GetUserDetail(); $res = array(); $domains = self::ListVhosts($currentuser['userid']); if (!fs_director::CheckForEmptyValue($domains)) { foreach ($domains as $row) { $filepath = '/var/sentora/logs/domains/' . $currentuser['username'] . '/' . $row['name'] . '-error.log'; if (file_exists($filepath)) { //fs_director::ShowHumanFileSize($used) $fsize = fs_director::ShowHumanFileSize(filesize($filepath)); } else { $fsize = 'Not Found'; } $res[] = array('name' => $row['name'], 'directory' => $row['directory'], 'active' => $row['active'], 'filepath' => basename($filepath), 'fsize' => $fsize, 'id' => $row['id']); } return $res; } else { return false; } }
<link href="../../../etc/styles/<?php echo $currentuser['usertheme']; ?> /css/<?php echo $currentuser['usercss']; ?> .css" rel="stylesheet" type="text/css"> <script src="../assets/ajaxsbmt.js" type="text/javascript"></script> <script src="http://code.jquery.com/jquery-latest.js"></script> <body style="background: #F3F3F3;"> <div style="margin-left:20px;margin-right:20px;"> <div class="zform_wrapper"> <h2>Backup your hosting account files</h2> <p>Your data is ready to be backed up. This proccess can take a lot of time, depending on your directory size. When finished you will be prompted to download your archive.</p> <p>Current public directory size: <b><?php echo fs_director::ShowHumanFileSize(dirSize(ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html")); ?> </b></p> <div id="BackupSubmit" style="height:100%;margin:auto;"> <form name="doBackup" action="response_normal.php" method="post" onsubmit="xmlhttpPost('dobackup.php?id=<?php echo $userid; ?> ', 'doBackup', 'BackupResult', 'Compressing your data, please wait...<br><img src=\'../assets/bar.gif\'>'); return false;"> <table class="zform"> <tr valign="top"> <th nowrap="nowrap"><button class="fg-button ui-state-default ui-corner-all" id="SubmitBackup" type="submit" name="inBackUp" value="">Backup Now</button></th> <td><input type="hidden" name="inDownLoad" id="inDownLoad" value="1" /></td> </tr> </table> </form> </div>
$domainssql = $zdbh->query("SELECT vh_acc_fk, vh_name_vc FROM x_vhosts WHERE vh_deleted_ts IS NULL"); while ($domain = $domainssql->fetch()) { $domainowner = ctrl_users::GetUserDetail($domain['vh_acc_fk']); $bandwidthlog = ctrl_options::GetSystemOption('log_dir') . 'domains/' . $domainowner['username'] . '/' . $domain['vh_name_vc'] . '-bandwidth.log'; $snapshotfile = ctrl_options::GetSystemOption('log_dir') . 'domains/' . $domainowner['username'] . '/' . $domain['vh_name_vc'] . '-snapshot.bw'; $bandwidth = 0; echo "Processing domain \"" . $domain['vh_name_vc'] . "\"" . fs_filehandler::NewLine(); if (fs_director::CheckFileExists($bandwidthlog)) { fs_filehandler::CopyFile($bandwidthlog, $snapshotfile); if (fs_director::CheckFileExists($snapshotfile)) { fs_filehandler::ResetFile($bandwidthlog); echo "Generating bandwidth.. " . fs_filehandler::NewLine(); $bandwidth = sys_bandwidth::CalculateFromApacheLog($snapshotfile); if (file_exists($snapshotfile)) { @unlink($snapshotfile); echo "usage: " . $bandwidth . " (" . fs_director::ShowHumanFileSize($bandwidth) . ")" . fs_filehandler::NewLine(); } } } if (!fs_director::CheckForEmptyValue($bandwidth)) { //$zdbh->query("UPDATE x_bandwidth SET bd_transamount_bi=(bd_transamount_bi+" . $bandwidth . ") WHERE bd_acc_fk = " . $domain['vh_acc_fk'] . " AND bd_month_in = " . date("Ym") . ""); $numrows = $zdbh->prepare("UPDATE x_bandwidth SET bd_transamount_bi=(bd_transamount_bi+:bandwidth) WHERE bd_acc_fk = :vh_acc_fk AND bd_month_in = :date"); $numrows->bindParam(':bandwidth', $bandwidth); $date = date("Ym"); $numrows->bindParam(':date', $date); $numrows->bindParam(':vh_acc_fk', $domain['vh_acc_fk']); $numrows->execute(); } else { echo "No bandwidth used, skipping!" . fs_filehandler::NewLine(); } //$checksize = $zdbh->query("SELECT * FROM x_bandwidth WHERE bd_month_in = " . date("Ym") . " AND bd_acc_fk = " . $domain['vh_acc_fk'] . "")->fetch();
static function ListClients($uid = 0) { global $zdbh; $sql = "SELECT * FROM x_accounts WHERE ac_deleted_ts IS NOT NULL"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':uid', $uid); $numrows->execute(); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); if ($uid == 0) { //do not bind as there is no need } else { //else we bind the pram to the sql statment $sql->bindParam(':uid', $uid); } $res = array(); $sql->execute(); while ($rowclients = $sql->fetch()) { if ($rowclients['ac_user_vc'] != "zadmin") { $numrows = $zdbh->prepare("SELECT COUNT(*) FROM x_accounts WHERE ac_reseller_fk=:ac_id_pk AND ac_deleted_ts IS NULL"); $numrows->bindParam(':ac_id_pk', $rowclients['ac_id_pk']); $numrows->execute(); $numrowclients = $numrows->fetch(); $currentuser = ctrl_users::GetUserDetail($rowclients['ac_id_pk']); $currentuser['diskspacereadable'] = fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid'])); $currentuser['diskspacequotareadable'] = fs_director::ShowHumanFileSize($currentuser['diskquota']); $currentuser['bandwidthreadable'] = fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid'])); $currentuser['bandwidthquotareadable'] = fs_director::ShowHumanFileSize($currentuser['bandwidthquota']); $currentuser['numclients'] = $numrowclients[0]; array_push($res, $currentuser); } } return $res; } else { return false; } }