changed getquotas to use account objects as input
This commit is contained in:
parent
ab99775bc8
commit
4337a1c795
|
@ -192,13 +192,12 @@ function RndInt($Format){
|
|||
|
||||
|
||||
/* Whis function will return the quotas from the specified user If empty only filesystems with enabled quotas are returned
|
||||
* $type = 'user' or 'group'
|
||||
* $users = array of users or groupnames. If no user or groupname is defined,
|
||||
* $users = array of account objects. If $user is a string (user or group)
|
||||
* an array with all quota-enabled partitions will be returned in this case all returned values are 0 exept mointpoint[x][0]
|
||||
*/
|
||||
function getquotas($type,$users=array('+')) {
|
||||
function getquotas($users) {
|
||||
// define new object
|
||||
$return = new account();
|
||||
$return = $users;
|
||||
// get username and password of the current lam-admin
|
||||
$ldap_q = $_SESSION['ldap']->decrypt();
|
||||
/* $towrite has the following syntax:
|
||||
|
@ -210,6 +209,10 @@ function getquotas($type,$users=array('+')) {
|
|||
/* scriptServer is the IP to remote-host to which lam should connect via ssh
|
||||
* scriptPath is Path to lamdaemon.pl on remote system
|
||||
*/
|
||||
for($i=0; $i<count($return); $i++)
|
||||
// put string to trasmit together
|
||||
if ($return[$i]->general_username!='') $userstring .= $return[$i]->general_username." quota get ".$return[$i]->type."\n";
|
||||
else $userstring .= "+ quota get ".$return[$i]->type."\n";
|
||||
if (function_exists(proc_open)) {
|
||||
// New Code, requires PHP 4.3
|
||||
$descriptorspec = array(
|
||||
|
@ -226,30 +229,24 @@ function getquotas($type,$users=array('+')) {
|
|||
* $pipes[1] is readable handle to child stdout
|
||||
* any error is send to /dev/null
|
||||
*/
|
||||
foreach ($users as $user) {
|
||||
// put string to trasmit together
|
||||
$userstring = "$user quota get $type\n";
|
||||
// Write one output-line for every user
|
||||
fwrite($pipes[0], $userstring);
|
||||
}
|
||||
fclose($pipes[0]);
|
||||
while (!feof($pipes[1])) {
|
||||
$output = fgets($pipes[1], 1024);
|
||||
if ($output!='') $vals5[] = $output;
|
||||
if ($output!='') $output_array[] = $output;
|
||||
}
|
||||
fclose($pipes[1]);
|
||||
$return_value = proc_close($process);
|
||||
}
|
||||
}
|
||||
else { // PHP 4.3>
|
||||
$input = "";
|
||||
foreach ($users as $user) $input .= "$user quota get $type\n";
|
||||
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||
$pipe = popen("echo \"$userstring\"|$command" , 'r');
|
||||
$output = '';
|
||||
while(!feof($pipe)) {
|
||||
$output .= fread($pipe, 1024);
|
||||
if ($output!='') $vals5[] = $output;
|
||||
if ($output!='') $output_array[] = $output;
|
||||
}
|
||||
pclose($pipe);
|
||||
}
|
||||
|
@ -261,22 +258,29 @@ function getquotas($type,$users=array('+')) {
|
|||
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
||||
* soft inode limit, hard inode limit, grace inode period
|
||||
*/
|
||||
if (is_array($vals5))
|
||||
foreach ($vals5 as $vals3) {
|
||||
$vals = explode(':', $vals3);
|
||||
for ($i=0; $i<sizeof($vals)-1; $i++) {
|
||||
$vals2 = explode(',', $vals[$i]);
|
||||
for ($j=0; $j<sizeof($vals2); $j++) {
|
||||
$return->quota[$i][$j] = $vals2[$j];
|
||||
for ($i=0; $i<count($return); $i++) {
|
||||
$all_quota = explode(':', $output_array[$i]);
|
||||
for ($j=0; $j<sizeof($all_quota)-1; $j++) {
|
||||
$single_quota = explode(',', $all_quota[$j]);
|
||||
// unset not existing quotas from account-object
|
||||
// collect all existing mountpoints in array
|
||||
$real_quotas[] = $single_quota[0];
|
||||
for ($k=0; $k<sizeof($single_quota); $k++)
|
||||
$return[$i]->quota[$j][$k] = $single_quota[$k];
|
||||
if ($return[$i]->quota[$j][4]<time()) $return[$i]->quota[$j][4] = '';
|
||||
else $return[$i]->quota[$j][4] = strval(($return[$i]->quota[$j][4]-time())/3600) .' '. _('hours');
|
||||
if ($return[$i]->quota[$j][8]<time()) $return[$i]->quota[$j][8] = '';
|
||||
else $return[$i]->quota[$j][8] = strval(($return[$i]->quota[$j][8]-time())/3600) .' '. _('hours');
|
||||
}
|
||||
if ($return->quota[$i][4]<$time) $return->quota[$i][4] = '';
|
||||
else $return->quota[$i][4] = strval(($return->quota[$i][4]-$time)/3600) .' '. _('hours');
|
||||
if ($return->quota[$i][8]<$time) $return->quota[$i][8] = '';
|
||||
else $return->quota[$i][8] = strval(($return->quota[$i][8]-$time)/3600) .' '. _('hours');
|
||||
$j=0;
|
||||
while (isset($return[$i]->quota[$j][0]))
|
||||
// remove invalid quotas
|
||||
if (!in_array($return[$i]->quota[$j][0], $real_quotas)) unset($return[$i]->quota[$j]);
|
||||
else $j++;
|
||||
// Beautify array, repair index
|
||||
$return[$i]->quota = array_values($return[$i]->quota);
|
||||
}
|
||||
$return2[] = $return;
|
||||
}
|
||||
return $return2;
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,38 +93,25 @@ else if (count($_POST)==0) {
|
|||
$account_new ->type = 'group';
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('group');
|
||||
if (isset($account_new->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($account_new->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values[0]->quota); $j++)
|
||||
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($account_new->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$account_new->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$account_new->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$account_new->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$account_new->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($account_new));
|
||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($account_new->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($account_new->quota[$j][0], $real_quotas)) unset($account_new->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$account_new->quota = array_values($account_new->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Display general-page
|
||||
$select_local = 'general';
|
||||
}
|
||||
|
@ -284,15 +271,8 @@ switch ($_POST['select']) {
|
|||
if ($_POST['outputpdf']) {
|
||||
// Load quotas if not yet done because they are needed for the pdf-file
|
||||
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
|
||||
$values = getquotas('group', array($account_old->general_username));
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
if (is_object($values[0]) && isset($account_old)) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_old->$key = $val;
|
||||
}
|
||||
$quotas = getquotas(array($account_old));
|
||||
$account_new = $quotas[0];
|
||||
}
|
||||
// Create / display PDf-file
|
||||
createGroupPDF(array($account_new));
|
||||
|
@ -401,38 +381,25 @@ do { // X-Or, only one if() can be true
|
|||
}
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('group');
|
||||
if (isset($account_new->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($account_new->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values[0]->quota); $j++)
|
||||
if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($account_new->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$account_new->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$account_new->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$account_new->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$account_new->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($account_new));
|
||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($account_new->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($account_new->quota[$j][0], $real_quotas)) unset($account_new->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$account_new->quota = array_values($account_new->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// select general page after group has been loaded
|
||||
$select_local='general';
|
||||
break;
|
||||
|
@ -739,15 +706,8 @@ switch ($select_local) {
|
|||
// Quota Settings
|
||||
// Load quotas if not yet done
|
||||
if ($config_intern->scriptServer && !isset($account_new->quota[0]) ) { // load quotas
|
||||
$values = getquotas('group', array($account_new->general_username));
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
if (is_object($values[0]) && isset($account_old)) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_old->$key = $val;
|
||||
}
|
||||
$quotas = getquotas(array($account_new));
|
||||
$account_new = $quotas[0];
|
||||
}
|
||||
echo "<input name=\"select\" type=\"hidden\" value=\"samba\">\n";
|
||||
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
|
||||
|
|
|
@ -89,7 +89,7 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
|
|||
// Display general-page
|
||||
$select_local = 'general';
|
||||
}
|
||||
// Startcondition. useredit.php was called from outside to create a new group
|
||||
// Startcondition. useredit.php was called from outside to create a new user
|
||||
else if (count($_POST)==0) {
|
||||
// Create new account object with settings from default profile
|
||||
// Check if there are valid groups. Can not create user with no primary group
|
||||
|
@ -114,38 +114,25 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
|
|||
$account_new ->type = 'user';
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('user');
|
||||
if (isset($account_new->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($account_new->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values[0]->quota); $j++)
|
||||
if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($account_new->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$account_new->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$account_new->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$account_new->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$account_new->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($account_new));
|
||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($account_new->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($account_new->quota[$j][0], $real_quotas)) unset($account_new->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$account_new->quota = array_values($account_new->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Display general-page
|
||||
$select_local = 'general';
|
||||
}
|
||||
|
@ -518,15 +505,9 @@ switch ($_POST['select']) {
|
|||
if ($_POST['outputpdf']) {
|
||||
// Load quotas if not yet done because they are needed for the pdf-file
|
||||
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
|
||||
$values = getquotas('user', array($account_old->general_username));
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
if (is_object($values[0]) && isset($account_old)) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_old->$key = $val;
|
||||
}
|
||||
$quotas = getquotas(array($account_old));
|
||||
$account_new = $quotas[0];
|
||||
$account_new->quota = $account_old->quota;
|
||||
}
|
||||
// Create / display PDf-file
|
||||
createUserPDF(array($account_new));
|
||||
|
@ -689,38 +670,25 @@ do { // X-Or, only one if() can be true
|
|||
$account_new->smb_smbhome = str_replace('$user', $account_new->general_username, $account_new->smb_smbhome);
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('user');
|
||||
if (isset($account_new->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($account_new->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values->quota); $j++)
|
||||
if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($account_new->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$account_new->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$account_new->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$account_new->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$account_new->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($account_new));
|
||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($account_new->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($account_new->quota[$j][0], $real_quotas)) unset($account_new->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$account_new->quota = array_values($account_new->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// select general page after group has been loaded
|
||||
$select_local='general';
|
||||
break;
|
||||
|
@ -1410,15 +1378,8 @@ switch ($select_local) {
|
|||
// Quota Settings
|
||||
// Load quotas if not yet done
|
||||
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
|
||||
$values = getquotas('user', array($account_old->general_username));
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_new->$key = $val;
|
||||
}
|
||||
if (is_object($values[0]) && isset($account_old)) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $account_old->$key = $val;
|
||||
}
|
||||
$quotas = getquotas(array($account_old));
|
||||
$account_new = $quotas[0];
|
||||
}
|
||||
echo "<input name=\"select\" type=\"hidden\" value=\"quota\">\n";
|
||||
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
|
||||
|
|
|
@ -173,38 +173,25 @@ switch ($select) {
|
|||
// load quotas from profile and check if they are valid
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('group');
|
||||
if (isset($group->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($group->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values[0]->quota); $j++)
|
||||
if ($values[0]->quota[$j][0]==$group->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($group->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$group->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$group->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$group->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$group->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($group));
|
||||
for ($i=0; $i<count($group->quota); $i++) $profile_quotas[] = $group->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $group->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $group->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($group->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($group->quota[$j][0], $real_quotas)) unset($group->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$group->quota = array_values($group->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $group->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get groupname from current user
|
||||
$group->general_username=$_SESSION['accounts'][$_SESSION['pointer']]->general_group;
|
||||
// gid Number
|
||||
|
@ -467,38 +454,25 @@ function loadfile() {
|
|||
$profile->type = 'user';
|
||||
if ($config_intern->scriptServer) {
|
||||
// load quotas and check if quotas from profile are valid
|
||||
$values = getquotas('user');
|
||||
if (isset($profile->quota[0])) {
|
||||
// check quotas from profile
|
||||
$i=0;
|
||||
// check quota settings, loop for every partition with quotas
|
||||
while (isset($profile->quota[$i])) {
|
||||
// search if quotas from profile fit to a real quota
|
||||
$found = (-1);
|
||||
for ($j=0; $j<count($values[0]->quota); $j++)
|
||||
if ($values[0]->quota[$j][0]==$profile->quota[$i][0]) $found = $j;
|
||||
// unset quota from profile if quotas (mointpoint) doesn't exists anymore
|
||||
if ($found==-1) unset($profile->quota[$i]);
|
||||
else {
|
||||
// Set missing part in quota-array
|
||||
$profile->quota[$i][1] = $values[0]->quota[$found][1];
|
||||
$profile->quota[$i][5] = $values[0]->quota[$found][5];
|
||||
$profile->quota[$i][4] = $values[0]->quota[$found][4];
|
||||
$profile->quota[$i][8] = $values[0]->quota[$found][8];
|
||||
$i++;
|
||||
$quotas = getquotas(array($profile));
|
||||
for ($i=0; $i<count($profile->quota); $i++) $profile_quotas[] = $profile->quota[$i][0];
|
||||
for ($i=0; $i<count($quotas[0]->quota); $i++) {
|
||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
||||
if (is_array($profile_quotas)) {
|
||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $profile->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
else $profile->quota[]=$quotas[0]->quota[$i];
|
||||
}
|
||||
$j=0;
|
||||
// delete not existing quotas
|
||||
while (isset($profile->quota[$j][0])) {
|
||||
// remove invalid quotas
|
||||
if (!in_array($profile->quota[$j][0], $real_quotas)) unset($profile->quota[$j]);
|
||||
else $j++;
|
||||
}
|
||||
// Beautify array, repair index
|
||||
$profile->quota = array_values($profile->quota);
|
||||
}
|
||||
else { // No quotas saved in profile
|
||||
// Display quotas for new users (Quota set to 0)
|
||||
if (is_object($values[0])) {
|
||||
while (list($key, $val) = each($values[0])) // Set only defined values
|
||||
if (isset($val)) $profile->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get keys to en/decrypt passwords
|
||||
$iv = base64_decode($_COOKIE["IV"]);
|
||||
$key = base64_decode($_COOKIE["Key"]);
|
||||
|
|
Loading…
Reference in New Issue