changed all lamdaemon.pl related functions
to support arrays and scalar variables Changed loaduser to load multiple users at once
This commit is contained in:
parent
b833b838a2
commit
e9ad4e446a
|
@ -192,12 +192,14 @@ function RndInt($Format){
|
||||||
|
|
||||||
|
|
||||||
/* Whis function will return the quotas from the specified user If empty only filesystems with enabled quotas are returned
|
/* Whis function will return the quotas from the specified user If empty only filesystems with enabled quotas are returned
|
||||||
* $users = array of account objects.
|
* $users = array of account objects., return-value is an array of account objects
|
||||||
|
* if $users is account object return values is also an account object
|
||||||
* An array with all quota-enabled partitions will be returned in this case all returned values are 0 exept mointpoint[x][0]
|
* An array with all quota-enabled partitions will be returned in this case all returned values are 0 exept mointpoint[x][0]
|
||||||
*/
|
*/
|
||||||
function getquotas($users) {
|
function getquotas($users) {
|
||||||
// define new object
|
// define new object
|
||||||
$return = $users;
|
if (is_array($users)) $return = $users;
|
||||||
|
else $return[0] = $users;
|
||||||
// get username and password of the current lam-admin
|
// get username and password of the current lam-admin
|
||||||
$ldap_q = $_SESSION['ldap']->decrypt();
|
$ldap_q = $_SESSION['ldap']->decrypt();
|
||||||
/* $towrite has the following syntax:
|
/* $towrite has the following syntax:
|
||||||
|
@ -209,10 +211,12 @@ function getquotas($users) {
|
||||||
/* scriptServer is the IP to remote-host to which lam should connect via ssh
|
/* scriptServer is the IP to remote-host to which lam should connect via ssh
|
||||||
* scriptPath is Path to lamdaemon.pl on remote system
|
* scriptPath is Path to lamdaemon.pl on remote system
|
||||||
*/
|
*/
|
||||||
|
if (is_array($return)) {
|
||||||
for($i=0; $i<count($return); $i++)
|
for($i=0; $i<count($return); $i++)
|
||||||
// put string to trasmit together
|
// put string to trasmit together
|
||||||
if ($return[$i]->general_username!='') $userstring .= $return[$i]->general_username." quota get ".$return[$i]->type."\n";
|
if ($return[$i]->general_username!='') $userstring .= $return[$i]->general_username." quota get ".$return[$i]->type."\n";
|
||||||
else $userstring .= "+ quota get ".$return[$i]->type."\n";
|
else $userstring .= "+ quota get ".$return[$i]->type."\n";
|
||||||
|
}
|
||||||
if (function_exists(proc_open)) {
|
if (function_exists(proc_open)) {
|
||||||
// New Code, requires PHP 4.3
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
|
@ -237,7 +241,7 @@ function getquotas($users) {
|
||||||
if ($output!='') $output_array[] = $output;
|
if ($output!='') $output_array[] = $output;
|
||||||
}
|
}
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
proc_close($process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // PHP 4.3>
|
else { // PHP 4.3>
|
||||||
|
@ -281,7 +285,8 @@ function getquotas($users) {
|
||||||
// Beautify array, repair index
|
// Beautify array, repair index
|
||||||
if (is_array($return[$i]->quota)) $return[$i]->quota = array_values($return[$i]->quota);
|
if (is_array($return[$i]->quota)) $return[$i]->quota = array_values($return[$i]->quota);
|
||||||
}
|
}
|
||||||
return $return;
|
if (is_array($users)) return $return;
|
||||||
|
else return $return[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $users;
|
return $users;
|
||||||
|
@ -290,8 +295,7 @@ function getquotas($users) {
|
||||||
|
|
||||||
/* Whis function will set the quotas from the specified user.
|
/* Whis function will set the quotas from the specified user.
|
||||||
* $values2 = array of object account with quotas which should be set
|
* $values2 = array of object account with quotas which should be set
|
||||||
* $values2_old = array of object account if set values and values_old will be compared. Quota will only be changed
|
* $values2 can also be an account object
|
||||||
* if values differ
|
|
||||||
*/
|
*/
|
||||||
function setquotas($values2) {
|
function setquotas($values2) {
|
||||||
// get username and password of the current lam-admin
|
// get username and password of the current lam-admin
|
||||||
|
@ -302,6 +306,40 @@ function setquotas($values2) {
|
||||||
*/
|
*/
|
||||||
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
||||||
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
||||||
|
|
||||||
|
/* Check wich quotas have changed
|
||||||
|
* Because we can not send an array to lamdaemon.pl we have to put all
|
||||||
|
* values in a string. ':' sepraeates the first array, ',' the second
|
||||||
|
*
|
||||||
|
* $values->quota[][] First array is an index for every chare with active quotas
|
||||||
|
* second array Contains values for every share:
|
||||||
|
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
||||||
|
* soft inode limit, hard inode limit, grace inode period
|
||||||
|
*
|
||||||
|
* run only once if no array is given
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (is_array($values2)) {
|
||||||
|
foreach ($values2 as $values) {
|
||||||
|
$i=0;
|
||||||
|
while ($values->quota[$i][0]) {
|
||||||
|
$quotastring = $quotastring. $values->quota[$i][0] .','.$values->quota[$i][2] .','.$values->quota[$i][3]
|
||||||
|
.','.$values->quota[$i][6] .','. $values->quota[$i][7] .':';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$userstring .= $values->general_username." quota set ".$values->type." ".$quotastring."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$i=0;
|
||||||
|
while ($values2->quota[$i][0]) {
|
||||||
|
$quotastring = $quotastring. $values2->quota[$i][0] .','.$values2->quota[$i][2] .','.$values2->quota[$i][3]
|
||||||
|
.','.$values2->quota[$i][6] .','. $values2->quota[$i][7] .':';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$userstring = $values2->general_username." quota set ".$values2->type." ".$quotastring."\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (function_exists(proc_open)) {
|
if (function_exists(proc_open)) {
|
||||||
// New Code, requires PHP 4.3
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
|
@ -318,67 +356,35 @@ function setquotas($values2) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
* $pipes[1] is readable handle to child stdout
|
||||||
* any error is send to /dev/null
|
* any error is send to /dev/null
|
||||||
*/
|
*/
|
||||||
foreach ($values2 as $values) {
|
|
||||||
$i=0;
|
|
||||||
/* Check wich quotas have changed
|
|
||||||
* Because we can not send an array to lamdaemon.pl we have to put all
|
|
||||||
* values in a string. ':' sepraeates the first array, ',' the second
|
|
||||||
*
|
|
||||||
* $values->quota[][] First array is an index for every chare with active quotas
|
|
||||||
* second array Contains values for every share:
|
|
||||||
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
|
||||||
* soft inode limit, hard inode limit, grace inode period
|
|
||||||
*/
|
|
||||||
while ($values->quota[$i][0]) {
|
|
||||||
if ($values->quota[$i] != $values_old->quota[$i]) {
|
|
||||||
$quotastring = $quotastring. $values->quota[$i][0] .','.$values->quota[$i][2] .','.$values->quota[$i][3]
|
|
||||||
.','.$values->quota[$i][6] .','. $values->quota[$i][7] .':';
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$userstring = $values->general_username." quota set ".$values->type." ".$quotastring."\n";
|
|
||||||
// Write to stdin
|
// Write to stdin
|
||||||
fwrite($pipes[0], $userstring);
|
fwrite($pipes[0], $userstring);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
while (!feof($pipes[1])) {
|
||||||
|
$output = fgets($pipes[1], 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
|
}
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
proc_close($process);
|
||||||
}
|
}
|
||||||
else { // PHP 4.3>
|
else { // PHP 4.3>
|
||||||
$input = "";
|
|
||||||
foreach ($values2 as $values) {
|
|
||||||
$i=0;
|
|
||||||
/* Check wich quotas have changed
|
|
||||||
* Because we can not send an array to lamdaemon.pl we have to put all
|
|
||||||
* values in a string. ':' sepraeates the first array, ',' the second
|
|
||||||
*
|
|
||||||
* $values->quota[][] First array is an index for every chare with active quotas
|
|
||||||
* second array Contains values for every share:
|
|
||||||
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
|
||||||
* soft inode limit, hard inode limit, grace inode period
|
|
||||||
*/
|
|
||||||
while ($values->quota[$i][0]) {
|
|
||||||
if ($values->quota[$i] != $values_old->quota[$i]) {
|
|
||||||
$quotastring = $quotastring. $values->quota[$i][0] .','.$values->quota[$i][2] .','.$values->quota[$i][3]
|
|
||||||
.','.$values->quota[$i][6] .','. $values->quota[$i][7] .':';
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$input .= $values->general_username." quota set ".$values->type." ".$quotastring."\n";
|
|
||||||
}
|
|
||||||
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
$pipe = popen("echo \"$input\"|$command" , 'r');
|
$pipe = popen("echo \"$userstring\"|$command" , 'r');
|
||||||
while(!feof($pipe)) {
|
while(!feof($pipe)) {
|
||||||
$return[] = fgets($pipe, 1024);
|
//$output .= fread($pipe, 1024);
|
||||||
|
$output = fgets($pipe, 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
}
|
}
|
||||||
pclose($pipe);
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
|
if (is_array($values2)) return $output_array;
|
||||||
|
else return $output_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Whis function will remove the quotas from the specified user.
|
/* Whis function will remove the quotas from the specified user.
|
||||||
* $user = array of usernames of which quta should be deleted
|
* $users = array of usernames of which quta should be deleted
|
||||||
|
* $users can also be a string (single user)
|
||||||
* $type = user or group
|
* $type = user or group
|
||||||
* Delteing quotas means settings all values to 0 which means no quotas
|
* Delteing quotas means settings all values to 0 which means no quotas
|
||||||
*/
|
*/
|
||||||
|
@ -391,6 +397,14 @@ function remquotas($users, $type) {
|
||||||
*/
|
*/
|
||||||
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
||||||
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
||||||
|
|
||||||
|
if (is_array($users)) {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$userstring .= "$user quota rem $type\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $userstring = "$users quota rem $type\n";
|
||||||
|
|
||||||
if (function_exists(proc_open)) {
|
if (function_exists(proc_open)) {
|
||||||
// New Code, requires PHP 4.3
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
|
@ -407,27 +421,29 @@ function remquotas($users, $type) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
* $pipes[1] is readable handle to child stdout
|
||||||
* any error is send to /dev/null
|
* any error is send to /dev/null
|
||||||
*/
|
*/
|
||||||
foreach ($users as $user) {
|
|
||||||
$userstring = "$user quota rem $type\n";
|
|
||||||
// Write to stdin
|
// Write to stdin
|
||||||
fwrite($pipes[0], $userstring);
|
fwrite($pipes[0], $userstring);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
while (!feof($pipes[1])) {
|
||||||
|
$output = fgets($pipes[1], 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
|
}
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
proc_close($process);
|
||||||
}
|
}
|
||||||
else { // PHP 4.3>
|
else { // PHP 4.3>
|
||||||
$input = "";
|
|
||||||
foreach ($users as $user) $userstring .= "$user quota rem $type\n";
|
|
||||||
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
$pipe = popen("echo \"$input\"|$command" , 'r');
|
$pipe = popen("echo \"$userstring\"|$command" , 'r');
|
||||||
$output = '';
|
|
||||||
while(!feof($pipe)) {
|
while(!feof($pipe)) {
|
||||||
$return[] = fgets($pipe, 1024);
|
//$output .= fread($pipe, 1024);
|
||||||
|
$output = fgets($pipe, 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
}
|
}
|
||||||
pclose($pipe);
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
|
if (is_array($values2)) return $output_array;
|
||||||
|
else return $output_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -435,6 +451,7 @@ function remquotas($users, $type) {
|
||||||
* lamdaemon.pl uses getpwnam on remote system to get homedir path.
|
* lamdaemon.pl uses getpwnam on remote system to get homedir path.
|
||||||
* Therefore ldap have to be used on remote system for user accounts
|
* Therefore ldap have to be used on remote system for user accounts
|
||||||
* $users = array of usernames
|
* $users = array of usernames
|
||||||
|
* $users can also be a string (single user)
|
||||||
*/
|
*/
|
||||||
function addhomedir($users) {
|
function addhomedir($users) {
|
||||||
// get username and password of the current lam-admin
|
// get username and password of the current lam-admin
|
||||||
|
@ -445,6 +462,14 @@ function addhomedir($users) {
|
||||||
*/
|
*/
|
||||||
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
||||||
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
||||||
|
|
||||||
|
if (is_array($users)) {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$userstring .= "$user home add\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $userstring = "$users home add\n";
|
||||||
|
|
||||||
if (function_exists(proc_open)) {
|
if (function_exists(proc_open)) {
|
||||||
// New Code, requires PHP 4.3
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
|
@ -461,27 +486,29 @@ function addhomedir($users) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
* $pipes[1] is readable handle to child stdout
|
||||||
* any error is send to /dev/null
|
* any error is send to /dev/null
|
||||||
*/
|
*/
|
||||||
foreach ($users as $user) {
|
|
||||||
$userstring = "$user home add\n";
|
|
||||||
// Write to stdin
|
// Write to stdin
|
||||||
fwrite($pipes[0], $userstring);
|
fwrite($pipes[0], $userstring);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
while (!feof($pipes[1])) {
|
||||||
|
$output = fgets($pipes[1], 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
|
}
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
proc_close($process);
|
||||||
}
|
}
|
||||||
else { // PHP 4.3>
|
else { // PHP 4.3>
|
||||||
$input = "";
|
|
||||||
foreach ($users as $user) $userstring .= "$user home add\n";
|
|
||||||
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
$pipe = popen("echo \"$input\"|$command" , 'r');
|
$pipe = popen("echo \"$userstring\"|$command" , 'r');
|
||||||
$output = '';
|
|
||||||
while(!feof($pipe)) {
|
while(!feof($pipe)) {
|
||||||
$return[] = fread($pipe, 1024);
|
//$output .= fread($pipe, 1024);
|
||||||
|
$output = fgets($pipe, 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
}
|
}
|
||||||
pclose($pipe);
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
|
if (is_array($values2)) return $output_array;
|
||||||
|
else return $output_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove Homedirectory
|
/* Remove Homedirectory
|
||||||
|
@ -490,6 +517,7 @@ function addhomedir($users) {
|
||||||
* This also means you have to remove the homedirectory before the
|
* This also means you have to remove the homedirectory before the
|
||||||
* account is removed from ldap
|
* account is removed from ldap
|
||||||
* $users = array of usernames
|
* $users = array of usernames
|
||||||
|
* $users can also be a string (single user)
|
||||||
*/
|
*/
|
||||||
function remhomedir($users) {
|
function remhomedir($users) {
|
||||||
// get username and password of the current lam-admin
|
// get username and password of the current lam-admin
|
||||||
|
@ -500,6 +528,14 @@ function remhomedir($users) {
|
||||||
*/
|
*/
|
||||||
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
$towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
|
||||||
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
|
||||||
|
|
||||||
|
if (is_array($users)) {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$userstring .= "$user home rem\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $userstring = "$users home rem\n";
|
||||||
|
|
||||||
if (function_exists(proc_open)) {
|
if (function_exists(proc_open)) {
|
||||||
// New Code, requires PHP 4.3
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
|
@ -516,27 +552,29 @@ function remhomedir($users) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
* $pipes[1] is readable handle to child stdout
|
||||||
* any error is send to /dev/null
|
* any error is send to /dev/null
|
||||||
*/
|
*/
|
||||||
foreach ($users as $user) {
|
|
||||||
$userstring = "$user home rem\n";
|
|
||||||
// Write to stdin
|
// Write to stdin
|
||||||
fwrite($pipes[0], $userstring);
|
fwrite($pipes[0], $userstring);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
while (!feof($pipes[1])) {
|
||||||
|
$output = fgets($pipes[1], 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
|
}
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
proc_close($process);
|
||||||
}
|
}
|
||||||
else { // PHP 4.3>
|
else { // PHP 4.3>
|
||||||
$input = "";
|
|
||||||
foreach ($users as $user) $userstring .= "$user home rem\n";
|
|
||||||
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
$pipe = popen("echo \"$input\"|$command" , 'r');
|
$pipe = popen("echo \"$userstring\"|$command" , 'r');
|
||||||
$output = '';
|
|
||||||
while(!feof($pipe)) {
|
while(!feof($pipe)) {
|
||||||
$return[] = fgets($pipe, 1024);
|
//$output .= fread($pipe, 1024);
|
||||||
|
$output = fgets($pipe, 1024);
|
||||||
|
if ($output!='') $output_array[] = $output;
|
||||||
}
|
}
|
||||||
pclose($pipe);
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
|
if (is_array($values2)) return $output_array;
|
||||||
|
else return $output_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -886,90 +924,112 @@ function smbflag($values) {
|
||||||
|
|
||||||
|
|
||||||
/* This function will load all needed values from an existing user account
|
/* This function will load all needed values from an existing user account
|
||||||
* $dn is the dn(string) of the user which should be loaded
|
* $dns is an array of dns(string) of the users which should be loaded
|
||||||
* return-value is an account-object
|
* return-value is an array of account-objects
|
||||||
|
* $dns can also be an string. Then return-value is a single string too
|
||||||
*/
|
*/
|
||||||
function loaduser($dn) {
|
function loaduser($dns) {
|
||||||
// Create new object
|
|
||||||
$return = new account();
|
|
||||||
// Set type of account
|
|
||||||
$return->type='user';
|
|
||||||
// Load userattributes from ldap
|
// Load userattributes from ldap
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount");
|
//$result = ldap_search($_SESSION['ldap']->server(), $dn, "objectclass=PosixAccount");
|
||||||
|
// Get uid=$user from DN
|
||||||
|
// Put ldapsearch together
|
||||||
|
if (is_array($dns)) {
|
||||||
|
foreach ($dns as $dn)
|
||||||
|
$uids[] = substr($dn, 0, strpos($dn, ','));
|
||||||
|
$search = "(|";
|
||||||
|
foreach ($uids as $uid) $search .= "($uid)";
|
||||||
|
$search .= ")";
|
||||||
|
}
|
||||||
|
else $search = substr($dns, 0, strpos($dns, ','));
|
||||||
|
// search for users
|
||||||
|
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), $search);
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||||
$return->general_dn = ldap_get_dn($_SESSION['ldap']->server(), $entry);
|
// loop for every found user
|
||||||
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
$i=0;
|
||||||
|
while ($entry) {
|
||||||
|
// Only load user if it should be loaded
|
||||||
|
if (is_array($dns)) {
|
||||||
|
if (in_array(ldap_get_dn($_SESSION['ldap']->server(), $entry), $dns)) $continue=true;
|
||||||
|
else $continue=false;
|
||||||
|
}
|
||||||
|
else $continue=true;
|
||||||
|
if ($continue) {
|
||||||
|
// Create new object
|
||||||
|
$return[$i] = new account();
|
||||||
|
// Set type of account
|
||||||
|
$return[$i]->type='user';
|
||||||
// Set user samba flag
|
// Set user samba flag
|
||||||
$account_new->smb_flagsW = false;
|
$return[$i]->smb_flagsW = false;
|
||||||
|
$return[$i]->general_dn = ldap_get_dn($_SESSION['ldap']->server(), $entry);
|
||||||
|
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
||||||
/* Write attributes into $return.
|
/* Write attributes into $return.
|
||||||
* Some values don't have to be set. These are only loaded if they are set
|
* Some values don't have to be set. These are only loaded if they are set
|
||||||
*/
|
*/
|
||||||
$return->general_username = $attr['uid'][0];
|
$return[$i]->general_username = $attr['uid'][0];
|
||||||
$return->general_uidNumber = $attr['uidNumber'][0];
|
$return[$i]->general_uidNumber = $attr['uidNumber'][0];
|
||||||
$return->general_homedir = $attr['homeDirectory'][0];
|
$return[$i]->general_homedir = $attr['homeDirectory'][0];
|
||||||
if (isset($attr['shadowLastChange'][0])) $return->unix_shadowLastChange = $attr['shadowLastChange'][0];
|
if (isset($attr['shadowLastChange'][0])) $return[$i]->unix_shadowLastChange = $attr['shadowLastChange'][0];
|
||||||
if (isset($attr['loginShell'][0])) $return->general_shell = $attr['loginShell'][0];
|
if (isset($attr['loginShell'][0])) $return[$i]->general_shell = $attr['loginShell'][0];
|
||||||
if (isset($attr['gecos'][0])) $return->general_gecos = utf8_decode($attr['gecos'][0]);
|
if (isset($attr['gecos'][0])) $return[$i]->general_gecos = utf8_decode($attr['gecos'][0]);
|
||||||
|
|
||||||
// get groupname
|
// get groupname
|
||||||
$return->general_group = getgrnam($attr['gidNumber'][0]);
|
$return[$i]->general_group = getgrnam($attr['gidNumber'][0]);
|
||||||
|
|
||||||
// get all additional groupmemberships
|
// get all additional groupmemberships
|
||||||
// load all groups which have memberUid set to the username which should be loaded
|
// load all groups which have memberUid set to the username which should be loaded
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "memberUid=".$attr['uid'][0], array('cn'));
|
$result2 = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "memberUid=".$attr['uid'][0], array('cn'));
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
$entry2 = ldap_first_entry($_SESSION['ldap']->server(), $result2);
|
||||||
// loop for every group
|
// loop for every group
|
||||||
while ($entry) {
|
while ($entry2) {
|
||||||
$attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
$attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry2);
|
||||||
// Add groupnames to array
|
// Add groupnames to array
|
||||||
if ($attr2['cn'][0]!=$return->general_group) $return->general_groupadd[]=$attr2['cn'][0];
|
if ($attr2['cn'][0]!=$return[$i]->general_group) $return[$i]->general_groupadd[]=$attr2['cn'][0];
|
||||||
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
|
$entry2 = ldap_next_entry($_SESSION['ldap']->server(), $entry2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write attributes into $return.
|
/* Write attributes into $return.
|
||||||
* Some values don't have to be set. These are only loaded if they are set
|
* Some values don't have to be set. These are only loaded if they are set
|
||||||
*/
|
*/
|
||||||
if (isset($attr['shadowMin'][0])) $return->unix_pwdminage = $attr['shadowMin'][0];
|
if (isset($attr['shadowMin'][0])) $return[$i]->unix_pwdminage = $attr['shadowMin'][0];
|
||||||
if (isset($attr['shadowMax'][0])) $return->unix_pwdmaxage = $attr['shadowMax'][0];
|
if (isset($attr['shadowMax'][0])) $return[$i]->unix_pwdmaxage = $attr['shadowMax'][0];
|
||||||
if (isset($attr['shadowWarning'][0])) $return->unix_pwdwarn = $attr['shadowWarning'][0];
|
if (isset($attr['shadowWarning'][0])) $return[$i]->unix_pwdwarn = $attr['shadowWarning'][0];
|
||||||
if (isset($attr['shadowInactive'][0])) $return->unix_pwdallowlogin = $attr['shadowInactive'][0];
|
if (isset($attr['shadowInactive'][0])) $return[$i]->unix_pwdallowlogin = $attr['shadowInactive'][0];
|
||||||
if (isset($attr['shadowExpire'][0])) $return->unix_pwdexpire = $attr['shadowExpire'][0]*86400;
|
if (isset($attr['shadowExpire'][0])) $return[$i]->unix_pwdexpire = $attr['shadowExpire'][0]*86400;
|
||||||
|
|
||||||
// load hosts attributes if set
|
// load hosts attributes if set
|
||||||
$i=0;
|
$j=0;
|
||||||
while (isset($attr['host'][$i])) {
|
while (isset($attr['host'][$j])) {
|
||||||
if ($i==0) $return->unix_host = $attr['host'][$i];
|
if ($j==0) $return[$i]->unix_host = $attr['host'][$j];
|
||||||
else $return->unix_host = $return->unix_host . ', ' . $attr['host'][$i];
|
else $return[$i]->unix_host = $return[$i]->unix_host . ', ' . $attr['host'][$j];
|
||||||
$i++;
|
$j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load objectclasses
|
// load objectclasses
|
||||||
$i=0;
|
$j=0;
|
||||||
while (isset($attr['objectClass'][$i])) {
|
while (isset($attr['objectClass'][$j])) {
|
||||||
$return->general_objectClass[$i] = $attr['objectClass'][$i];
|
$return[$i]->general_objectClass[$j] = $attr['objectClass'][$j];
|
||||||
$i++;
|
$j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load personal settings
|
// load personal settings
|
||||||
if (isset($attr['givenName'][0])) $return->general_givenname = utf8_decode($attr['givenName'][0]);
|
if (isset($attr['givenName'][0])) $return[$i]->general_givenname = utf8_decode($attr['givenName'][0]);
|
||||||
if (isset($attr['sn'][0])) $return->general_surname = utf8_decode($attr['sn'][0]);
|
if (isset($attr['sn'][0])) $return[$i]->general_surname = utf8_decode($attr['sn'][0]);
|
||||||
if (isset($attr['title'][0])) $return->personal_title = utf8_decode($attr['title'][0]);
|
if (isset($attr['title'][0])) $return[$i]->personal_title = utf8_decode($attr['title'][0]);
|
||||||
if (isset($attr['mail'][0])) $return->personal_mail = utf8_decode($attr['mail'][0]);
|
if (isset($attr['mail'][0])) $return[$i]->personal_mail = utf8_decode($attr['mail'][0]);
|
||||||
if (isset($attr['telephoneNumber'][0])) $return->personal_telephoneNumber = utf8_decode($attr['telephoneNumber'][0]);
|
if (isset($attr['telephoneNumber'][0])) $return[$i]->personal_telephoneNumber = utf8_decode($attr['telephoneNumber'][0]);
|
||||||
if (isset($attr['mobileTelephoneNumber'][0])) $return->personal_mobileTelephoneNumber = utf8_decode($attr['mobileTelephoneNumber'][0]);
|
if (isset($attr['mobileTelephoneNumber'][0])) $return[$i]->personal_mobileTelephoneNumber = utf8_decode($attr['mobileTelephoneNumber'][0]);
|
||||||
else if (isset($attr['mobile'][0])) $return->personal_mobileTelephoneNumber = utf8_decode($attr['mobile'][0]);
|
else if (isset($attr['mobile'][0])) $return[$i]->personal_mobileTelephoneNumber = utf8_decode($attr['mobile'][0]);
|
||||||
if (isset($attr['facsimileTelephoneNumber'][0])) $return->personal_facsimileTelephoneNumber = utf8_decode($attr['facsimileTelephoneNumber'][0]);
|
if (isset($attr['facsimileTelephoneNumber'][0])) $return[$i]->personal_facsimileTelephoneNumber = utf8_decode($attr['facsimileTelephoneNumber'][0]);
|
||||||
if (isset($attr['street'][0])) $return->personal_street = utf8_decode($attr['street'][0]);
|
if (isset($attr['street'][0])) $return[$i]->personal_street = utf8_decode($attr['street'][0]);
|
||||||
if (isset($attr['postalCode'][0])) $return->personal_postalCode = utf8_decode($attr['postalCode'][0]);
|
if (isset($attr['postalCode'][0])) $return[$i]->personal_postalCode = utf8_decode($attr['postalCode'][0]);
|
||||||
if (isset($attr['postalAddress'][0])) $return->personal_postalAddress = utf8_decode($attr['postalAddress'][0]);
|
if (isset($attr['postalAddress'][0])) $return[$i]->personal_postalAddress = utf8_decode($attr['postalAddress'][0]);
|
||||||
if (isset($attr['employeeType'][0])) $return->personal_employeeType = utf8_decode($attr['employeeType'][0]);
|
if (isset($attr['employeeType'][0])) $return[$i]->personal_employeeType = utf8_decode($attr['employeeType'][0]);
|
||||||
|
|
||||||
if (isset($attr['userPassword'][0])) {
|
if (isset($attr['userPassword'][0])) {
|
||||||
$return->unix_password = $attr['userPassword'][0];
|
$return[$i]->unix_password = $attr['userPassword'][0];
|
||||||
$return->unix_deactivated=!pwd_is_enabled($attr['userPassword'][0]);
|
$return[$i]->unix_deactivated=!pwd_is_enabled($attr['userPassword'][0]);
|
||||||
}
|
}
|
||||||
if (isset($attr['displayName'][0])) $return->smb_displayName = utf8_decode($attr['displayName'][0]);
|
if (isset($attr['displayName'][0])) $return[$i]->smb_displayName = utf8_decode($attr['displayName'][0]);
|
||||||
|
|
||||||
// sambaSamAccount (Samba3) is used.
|
// sambaSamAccount (Samba3) is used.
|
||||||
if (in_array('sambaSamAccount', $attr['objectClass'])) {
|
if (in_array('sambaSamAccount', $attr['objectClass'])) {
|
||||||
|
@ -977,83 +1037,86 @@ function loaduser($dn) {
|
||||||
* Some values don't have to be set. These are only loaded if they are set
|
* Some values don't have to be set. These are only loaded if they are set
|
||||||
*/
|
*/
|
||||||
if (isset($attr['sambaAcctFlags'][0])) {
|
if (isset($attr['sambaAcctFlags'][0])) {
|
||||||
// a user is no workstation
|
if (strrpos($attr['sambaAcctFlags'][0], 'D')) $return[$i]->smb_flagsD=true;
|
||||||
$return->smb_flagsW=false;
|
if (strrpos($attr['sambaAcctFlags'][0], 'X')) $return[$i]->smb_flagsX=true;
|
||||||
if (strrpos($attr['sambaAcctFlags'][0], 'D')) $return->smb_flagsD=true;
|
|
||||||
if (strrpos($attr['sambaAcctFlags'][0], 'X')) $return->smb_flagsX=true;
|
|
||||||
}
|
}
|
||||||
if (isset($attr['sambaPwdCanChange'][0])) $return->smb_pwdcanchange = $attr['sambaPwdCanChange'][0];
|
if (isset($attr['sambaPwdCanChange'][0])) $return[$i]->smb_pwdcanchange = $attr['sambaPwdCanChange'][0];
|
||||||
if (isset($attr['sambaPwdMustChange'][0])) $return->smb_pwdmustchange = $attr['sambaPwdMustChange'][0];
|
if (isset($attr['sambaPwdMustChange'][0])) $return[$i]->smb_pwdmustchange = $attr['sambaPwdMustChange'][0];
|
||||||
if (isset($attr['sambaHomePath'][0])) $return->smb_smbhome = utf8_decode($attr['sambaHomePath'][0]);
|
if (isset($attr['sambaHomePath'][0])) $return[$i]->smb_smbhome = utf8_decode($attr['sambaHomePath'][0]);
|
||||||
if (isset($attr['sambaHomeDrive'][0])) $return->smb_homedrive = $attr['sambaHomeDrive'][0];
|
if (isset($attr['sambaHomeDrive'][0])) $return[$i]->smb_homedrive = $attr['sambaHomeDrive'][0];
|
||||||
if (isset($attr['sambaLogonScript'][0])) $return->smb_scriptPath = utf8_decode($attr['sambaLogonScript'][0]);
|
if (isset($attr['sambaLogonScript'][0])) $return[$i]->smb_scriptPath = utf8_decode($attr['sambaLogonScript'][0]);
|
||||||
if (isset($attr['sambaProfilePath'][0])) $return->smb_profilePath = $attr['sambaProfilePath'][0];
|
if (isset($attr['sambaProfilePath'][0])) $return[$i]->smb_profilePath = $attr['sambaProfilePath'][0];
|
||||||
if (isset($attr['sambaUserWorkstations'][0])) $return->smb_smbuserworkstations = $attr['sambaUserWorkstations'][0];
|
if (isset($attr['sambaUserWorkstations'][0])) $return[$i]->smb_smbuserworkstations = $attr['sambaUserWorkstations'][0];
|
||||||
if (isset($attr['sambaNTPassword'][0])) $return->smb_password = $attr['sambaNTPassword'][0];
|
if (isset($attr['sambaNTPassword'][0])) $return[$i]->smb_password = $attr['sambaNTPassword'][0];
|
||||||
if (isset($attr['sambaDomainName'][0])) {
|
if (isset($attr['sambaDomainName'][0])) {
|
||||||
if ($_SESSION['config']->is_samba3()) {
|
if ($_SESSION['config']->is_samba3()) {
|
||||||
// store smb_domain as samba3domain-Object
|
// store smb_domain as samba3domain-Object
|
||||||
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
|
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
|
||||||
$i=0;
|
$j=0;
|
||||||
while (!isset($return->smb_domain) && (count($samba3domains)>$i)) {
|
while (!isset($return[$i]->smb_domain) && (count($samba3domains)>$j)) {
|
||||||
if ($attr['sambaDomainName'][0] == $samba3domains[$i]->name)
|
if ($attr['sambaDomainName'][0] == $samba3domains[$j]->name)
|
||||||
$return->smb_domain = $samba3domains[$i];
|
$return[$i]->smb_domain = $samba3domains[$j];
|
||||||
else $i++;
|
else $j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// store smb_domain as string
|
// store smb_domain as string
|
||||||
if (!isset($return->smb_domain)) $return->smb_domain = $attr['sambaDomainName'];
|
if (!isset($return[$i]->smb_domain)) $return[$i]->smb_domain = $attr['sambaDomainName'];
|
||||||
}
|
}
|
||||||
if (isset($attr['sambaPrimaryGroupSID'][0])) {
|
if (isset($attr['sambaPrimaryGroupSID'][0])) {
|
||||||
if ($_SESSION['config']->is_samba3())
|
if ($_SESSION['config']->is_samba3())
|
||||||
// store "real" SID if we want to save user as samba3 entry
|
// store "real" SID if we want to save user as samba3 entry
|
||||||
$return->smb_mapgroup = $attr['sambaPrimaryGroupSID'][0];
|
$return[$i]->smb_mapgroup = $attr['sambaPrimaryGroupSID'][0];
|
||||||
// store "calculated" id if we want to save user as samba2.2 entry
|
// store "calculated" id if we want to save user as samba2.2 entry
|
||||||
else $return->smb_mapgroup = 2*$attr['gidNumber'][0]+1001;
|
else $return[$i]->smb_mapgroup = 2*$attr['gidNumber'][0]+1001;
|
||||||
}
|
}
|
||||||
// return value to prevent loaded values to be overwritten from old samba 2.2 attributes
|
|
||||||
if ($_SESSION['config']->is_samba3()) return $return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sambaSamAccount (Samba2.2) is used.
|
// sambaSamAccount (Samba2.2) is used.
|
||||||
if (in_array('sambaAccount', $attr['objectClass'])) {
|
// second argument should prevent samba3 settings to be overwritten from samba 2.2 settings
|
||||||
|
if ( (in_array('sambaAccount', $attr['objectClass'])) && (!$_SESSION['config']->is_samba3() || !isset($return[$i]->smb_domain))) {
|
||||||
if (isset($attr['acctFlags'][0])) {
|
if (isset($attr['acctFlags'][0])) {
|
||||||
// a user is no workstation
|
if (strrpos($attr['acctFlags'][0], 'D')) $return[$i]->smb_flagsD=true;
|
||||||
$return->smb_flagsW=false;
|
if (strrpos($attr['acctFlags'][0], 'X')) $return[$i]->smb_flagsX=true;
|
||||||
if (strrpos($attr['acctFlags'][0], 'D')) $return->smb_flagsD=true;
|
|
||||||
if (strrpos($attr['acctFlags'][0], 'X')) $return->smb_flagsX=true;
|
|
||||||
}
|
}
|
||||||
if (isset($attr['ntPassword'][0])) $return->smb_password = $attr['ntPassword'][0];
|
if (isset($attr['ntPassword'][0])) $return[$i]->smb_password = $attr['ntPassword'][0];
|
||||||
if (isset($attr['smbHome'][0])) $return->smb_smbhome = utf8_decode($attr['smbHome'][0]);
|
if (isset($attr['smbHome'][0])) $return[$i]->smb_smbhome = utf8_decode($attr['smbHome'][0]);
|
||||||
if (isset($attr['pwdCanChange'][0])) $return->smb_pwdcanchange = $attr['pwdCanChange'][0];
|
if (isset($attr['pwdCanChange'][0])) $return[$i]->smb_pwdcanchange = $attr['pwdCanChange'][0];
|
||||||
if (isset($attr['pwdMustChange'][0])) $return->smb_pwdmustchange = $attr['pwdMustChange'][0];
|
if (isset($attr['pwdMustChange'][0])) $return[$i]->smb_pwdmustchange = $attr['pwdMustChange'][0];
|
||||||
if (isset($attr['homeDrive'][0])) $return->smb_homedrive = $attr['homeDrive'][0];
|
if (isset($attr['homeDrive'][0])) $return[$i]->smb_homedrive = $attr['homeDrive'][0];
|
||||||
if (isset($attr['scriptPath'][0])) $return->smb_scriptPath = utf8_decode($attr['scriptPath'][0]);
|
if (isset($attr['scriptPath'][0])) $return[$i]->smb_scriptPath = utf8_decode($attr['scriptPath'][0]);
|
||||||
if (isset($attr['profilePath'][0])) $return->smb_profilePath = $attr['profilePath'][0];
|
if (isset($attr['profilePath'][0])) $return[$i]->smb_profilePath = $attr['profilePath'][0];
|
||||||
if (isset($attr['userWorkstations'][0])) $return->smb_smbuserworkstations = $attr['userWorkstations'][0];
|
if (isset($attr['userWorkstations'][0])) $return[$i]->smb_smbuserworkstations = $attr['userWorkstations'][0];
|
||||||
if (isset($attr['domain'][0])) {
|
if (isset($attr['domain'][0])) {
|
||||||
if ($_SESSION['config']->is_samba3()) {
|
if ($_SESSION['config']->is_samba3()) {
|
||||||
// store smb_domain as samba3domain-Object
|
// store smb_domain as samba3domain-Object
|
||||||
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
|
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
|
||||||
$i=0;
|
$j=0;
|
||||||
while (!isset($return->smb_domain) && (count($samba3domains)>$i)) {
|
while (!isset($return[$i]->smb_domain) && (count($samba3domains)>$j)) {
|
||||||
if ($attr['domain'][0] == $samba3domains[$i]->name)
|
if ($attr['domain'][0] == $samba3domains[$j]->name)
|
||||||
$return->smb_domain = $samba3domains[$i];
|
$return[$i]->smb_domain = $samba3domains[$j];
|
||||||
else $i++;
|
else $j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// store smb_domain as string
|
// store smb_domain as string
|
||||||
if (!isset($return->smb_domain)) $return->smb_domain = $attr['domain'];
|
if (!isset($return[$i]->smb_domain)) $return[$i]->smb_domain = $attr['domain'];
|
||||||
}
|
}
|
||||||
if (isset($attr['primaryGroupID'][0])) {
|
if (isset($attr['primaryGroupID'][0])) {
|
||||||
if ($_SESSION['config']->is_samba3())
|
if ($_SESSION['config']->is_samba3())
|
||||||
// store "real" SID if we want to save user as samba3 entry
|
// store "real" SID if we want to save user as samba3 entry
|
||||||
$return->smb_mapgroup = $return->smb_domain->SID. '-' . (2*$attr['primaryGroupID'][0]+1);
|
$return[$i]->smb_mapgroup = $return[$i]->smb_domain->SID. '-' . (2*$attr['primaryGroupID'][0]+1);
|
||||||
// store "calculated" id if we want to save user as samba2.2 entry
|
// store "calculated" id if we want to save user as samba2.2 entry
|
||||||
else $return->smb_mapgroup = $attr['primaryGroupID'][0];
|
else $return[$i]->smb_mapgroup = $attr['primaryGroupID'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
}
|
||||||
|
$i++;
|
||||||
|
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return array if $dns is an array
|
||||||
|
// else return string
|
||||||
|
if (is_array($dns)) return $return;
|
||||||
|
else return $return[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,14 +113,14 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
|
||||||
$account_new ->type = 'user';
|
$account_new ->type = 'user';
|
||||||
if ($config_intern->scriptServer) {
|
if ($config_intern->scriptServer) {
|
||||||
// load quotas and check if quotas from profile are valid
|
// load quotas and check if quotas from profile are valid
|
||||||
$quotas = getquotas(array($account_new));
|
$quotas = getquotas($account_new);
|
||||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
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++) {
|
for ($i=0; $i<count($quotas->quota); $i++) {
|
||||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
$real_quotas[] = $quotas->quota[$i][0];
|
||||||
if (is_array($profile_quotas)) {
|
if (is_array($profile_quotas)) {
|
||||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
if (!in_array($quotas->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas->quota[$i];
|
||||||
}
|
}
|
||||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
else $account_new->quota[]=$quotas->quota[$i];
|
||||||
}
|
}
|
||||||
$j=0;
|
$j=0;
|
||||||
// delete not existing quotas
|
// delete not existing quotas
|
||||||
|
@ -509,8 +509,9 @@ switch ($_POST['select']) {
|
||||||
if ($_POST['outputpdf']) {
|
if ($_POST['outputpdf']) {
|
||||||
// Load quotas if not yet done because they are needed for the pdf-file
|
// 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
|
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
|
||||||
$quotas = getquotas(array($account_old));
|
$temp = getquotas($account_old);
|
||||||
$account_new->quota = $quotas[0]->quota;
|
$account_new->quota = $temp->quota;
|
||||||
|
unset($temp);
|
||||||
}
|
}
|
||||||
// Create / display PDf-file
|
// Create / display PDf-file
|
||||||
createUserPDF(array($account_new));
|
createUserPDF(array($account_new));
|
||||||
|
@ -673,15 +674,15 @@ do { // X-Or, only one if() can be true
|
||||||
$account_new->smb_smbhome = str_replace('$user', $account_new->general_username, $account_new->smb_smbhome);
|
$account_new->smb_smbhome = str_replace('$user', $account_new->general_username, $account_new->smb_smbhome);
|
||||||
if ($config_intern->scriptServer) {
|
if ($config_intern->scriptServer) {
|
||||||
// load quotas and check if quotas from profile are valid
|
// load quotas and check if quotas from profile are valid
|
||||||
if (isset($account_old)) $quotas = getquotas(array($account_old));
|
if (isset($account_old)) $quotas = getquotas($account_old);
|
||||||
else $quotas = getquotas(array($account_new));
|
else $quotas = getquotas($account_new);
|
||||||
for ($i=0; $i<count($account_new->quota); $i++) $profile_quotas[] = $account_new->quota[$i][0];
|
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++) {
|
for ($i=0; $i<count($quotas->quota); $i++) {
|
||||||
$real_quotas[] = $quotas[0]->quota[$i][0];
|
$real_quotas[] = $quotas->quota[$i][0];
|
||||||
if (is_array($profile_quotas)) {
|
if (is_array($profile_quotas)) {
|
||||||
if (!in_array($quotas[0]->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas[0]->quota[$i];
|
if (!in_array($quotas->quota[$i][0], $profile_quotas)) $account_new->quota[]=$quotas->quota[$i];
|
||||||
}
|
}
|
||||||
else $account_new->quota[]=$quotas[0]->quota[$i];
|
else $account_new->quota[]=$quotas->quota[$i];
|
||||||
}
|
}
|
||||||
$j=0;
|
$j=0;
|
||||||
// delete not existing quotas
|
// delete not existing quotas
|
||||||
|
@ -695,12 +696,12 @@ do { // X-Or, only one if() can be true
|
||||||
// Set used blocks
|
// Set used blocks
|
||||||
if (isset($account_old)) {
|
if (isset($account_old)) {
|
||||||
for ($i=0; $i<count($account_new->quota); $i++)
|
for ($i=0; $i<count($account_new->quota); $i++)
|
||||||
for ($j=0; $j<count($quotas[0]->quota); $j++)
|
for ($j=0; $j<count($quotas->quota); $j++)
|
||||||
if ($quotas[0]->quota[$j][0] == $account_new->quota[$i][0]) {
|
if ($quotas->quota[$j][0] == $account_new->quota[$i][0]) {
|
||||||
$account_new->quota[$i][1] = $quotas[0]->quota[$i][1];
|
$account_new->quota[$i][1] = $quotas->quota[$i][1];
|
||||||
$account_new->quota[$i][4] = $quotas[0]->quota[$i][4];
|
$account_new->quota[$i][4] = $quotas->quota[$i][4];
|
||||||
$account_new->quota[$i][5] = $quotas[0]->quota[$i][5];
|
$account_new->quota[$i][5] = $quotas->quota[$i][5];
|
||||||
$account_new->quota[$i][8] = $quotas[0]->quota[$i][8];
|
$account_new->quota[$i][8] = $quotas->quota[$i][8];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else for ($i=0; $i<count($account_new->quota); $i++) {
|
else for ($i=0; $i<count($account_new->quota); $i++) {
|
||||||
|
@ -1395,9 +1396,10 @@ switch ($select_local) {
|
||||||
case 'quota':
|
case 'quota':
|
||||||
// Quota Settings
|
// Quota Settings
|
||||||
// Load quotas if not yet done
|
// Load quotas if not yet done
|
||||||
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
|
if (($config_intern->scriptServer) && !isset($account_new->quota[0])) { // load quotas
|
||||||
$quotas = getquotas(array($account_old));
|
$temp = getquotas($account_old);
|
||||||
$account_new->quota = $quotas[0]->quota;
|
$account_new->quota = $temp->quota;
|
||||||
|
unset ($temp);
|
||||||
}
|
}
|
||||||
echo "<input name=\"select\" type=\"hidden\" value=\"quota\">\n";
|
echo "<input name=\"select\" type=\"hidden\" value=\"quota\">\n";
|
||||||
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
|
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
|
||||||
|
|
Loading…
Reference in New Issue