changed code to communicate with lamdaemon.pl
to support < PHP 4.3
This commit is contained in:
parent
78145c6288
commit
55e8c117ed
|
@ -210,33 +210,48 @@ function getquotas($type,$users=array('+')) {
|
||||||
/* 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
|
||||||
*/
|
*/
|
||||||
$descriptorspec = array(
|
if (function_exists(proc_open)) {
|
||||||
0 => array("pipe", "r"), // stdin
|
// New Code, requires PHP 4.3
|
||||||
1 => array("pipe", "w"), // stout
|
$descriptorspec = array(
|
||||||
2 => array("file", "/dev/null", "a") // sterr
|
0 => array("pipe", "r"), // stdin
|
||||||
);
|
1 => array("pipe", "w"), // stout
|
||||||
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
2 => array("file", "/dev/null", "a") // sterr
|
||||||
$descriptorspec,
|
);
|
||||||
$pipes);
|
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
||||||
if (is_resource($process)) {
|
$descriptorspec,
|
||||||
/* perl-script is running
|
$pipes);
|
||||||
* $pipes[0] is writeable handle to child stdin
|
if (is_resource($process)) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
/* perl-script is running
|
||||||
* any error is send to /dev/null
|
* $pipes[0] is writeable handle to child stdin
|
||||||
*/
|
* $pipes[1] is readable handle to child stdout
|
||||||
foreach ($users as $user) {
|
* any error is send to /dev/null
|
||||||
// put string to trasmit together
|
*/
|
||||||
$userstring = "$user quota get $type\n";
|
foreach ($users as $user) {
|
||||||
// Write one output-line for every user
|
// put string to trasmit together
|
||||||
fwrite($pipes[0], $userstring);
|
$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;
|
||||||
|
}
|
||||||
|
fclose($pipes[1]);
|
||||||
|
$return_value = proc_close($process);
|
||||||
}
|
}
|
||||||
fclose($pipes[0]);
|
}
|
||||||
while (!feof($pipes[1])) {
|
else { // PHP 4.3>
|
||||||
$output = fgets($pipes[1], 1024);
|
$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');
|
||||||
|
$output = '';
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$output .= fread($pipe, 1024);
|
||||||
if ($output!='') $vals5[] = $output;
|
if ($output!='') $vals5[] = $output;
|
||||||
}
|
}
|
||||||
fclose($pipes[1]);
|
pclose($pipe);
|
||||||
$return_value = proc_close($process);
|
|
||||||
}
|
}
|
||||||
/* $vals is a string which contains a two dimensional array.
|
/* $vals is a string which contains a two dimensional array.
|
||||||
* We have to recreate it with explode
|
* We have to recreate it with explode
|
||||||
|
@ -246,20 +261,21 @@ function getquotas($type,$users=array('+')) {
|
||||||
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
|
||||||
* soft inode limit, hard inode limit, grace inode period
|
* soft inode limit, hard inode limit, grace inode period
|
||||||
*/
|
*/
|
||||||
foreach ($vals5 as $vals3) {
|
if (is_array($vals5))
|
||||||
$vals = explode(':', $vals3);
|
foreach ($vals5 as $vals3) {
|
||||||
for ($i=0; $i<sizeof($vals)-1; $i++) {
|
$vals = explode(':', $vals3);
|
||||||
$vals2 = explode(',', $vals[$i]);
|
for ($i=0; $i<sizeof($vals)-1; $i++) {
|
||||||
for ($j=0; $j<sizeof($vals2); $j++) {
|
$vals2 = explode(',', $vals[$i]);
|
||||||
$return->quota[$i][$j] = $vals2[$j];
|
for ($j=0; $j<sizeof($vals2); $j++) {
|
||||||
|
$return->quota[$i][$j] = $vals2[$j];
|
||||||
|
}
|
||||||
|
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');
|
||||||
}
|
}
|
||||||
if ($return->quota[$i][4]<$time) $return->quota[$i][4] = '';
|
$return2[] = $return;
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
$return2[] = $return;
|
|
||||||
}
|
|
||||||
return $return2;
|
return $return2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,20 +294,51 @@ function setquotas($values2,$values2_old=false) {
|
||||||
*/
|
*/
|
||||||
$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]);
|
||||||
$descriptorspec = array(
|
if (function_exists(proc_open)) {
|
||||||
0 => array("pipe", "r"), // stdin
|
// New Code, requires PHP 4.3
|
||||||
1 => array("pipe", "w"), // stout
|
$descriptorspec = array(
|
||||||
2 => array("file", "/dev/null", "a") // sterr
|
0 => array("pipe", "r"), // stdin
|
||||||
);
|
1 => array("pipe", "w"), // stout
|
||||||
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
2 => array("file", "/dev/null", "a") // sterr
|
||||||
$descriptorspec,
|
);
|
||||||
$pipes);
|
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
||||||
if (is_resource($process)) {
|
$descriptorspec,
|
||||||
/* perl-script is running
|
$pipes);
|
||||||
* $pipes[0] is writeable handle to child stdin
|
if (is_resource($process)) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
/* perl-script is running
|
||||||
* any error is send to /dev/null
|
* $pipes[0] is writeable handle to child stdin
|
||||||
*/
|
* $pipes[1] is readable handle to child stdout
|
||||||
|
* 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
|
||||||
|
fwrite($pipes[0], $userstring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($pipes[0]);
|
||||||
|
fclose($pipes[1]);
|
||||||
|
$return_value = proc_close($process);
|
||||||
|
}
|
||||||
|
else { // PHP 4.3>
|
||||||
|
$input = "";
|
||||||
foreach ($values2 as $values) {
|
foreach ($values2 as $values) {
|
||||||
$i=0;
|
$i=0;
|
||||||
/* Check wich quotas have changed
|
/* Check wich quotas have changed
|
||||||
|
@ -310,14 +357,15 @@ function setquotas($values2,$values2_old=false) {
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$userstring = $values->general_username." quota set ".$values->type." ".$quotastring."\n";
|
$input .= $values->general_username." quota set ".$values->type." ".$quotastring."\n";
|
||||||
// Write to stdin
|
|
||||||
fwrite($pipes[0], $userstring);
|
|
||||||
}
|
}
|
||||||
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
|
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$return[] = fread($pipe, 1024);
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
fclose($pipes[0]);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
$return_value = proc_close($process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,29 +383,43 @@ 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]);
|
||||||
$descriptorspec = array(
|
if (function_exists(proc_open)) {
|
||||||
0 => array("pipe", "r"), // stdin
|
// New Code, requires PHP 4.3
|
||||||
1 => array("pipe", "w"), // stout
|
$descriptorspec = array(
|
||||||
2 => array("file", "/dev/null", "a") // sterr
|
0 => array("pipe", "r"), // stdin
|
||||||
);
|
1 => array("pipe", "w"), // stout
|
||||||
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
2 => array("file", "/dev/null", "a") // sterr
|
||||||
$descriptorspec,
|
);
|
||||||
$pipes);
|
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
||||||
if (is_resource($process)) {
|
$descriptorspec,
|
||||||
/* perl-script is running
|
$pipes);
|
||||||
* $pipes[0] is writeable handle to child stdin
|
if (is_resource($process)) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
/* perl-script is running
|
||||||
* any error is send to /dev/null
|
* $pipes[0] is writeable handle to child stdin
|
||||||
*/
|
* $pipes[1] is readable handle to child stdout
|
||||||
foreach ($users as $user) {
|
* any error is send to /dev/null
|
||||||
$userstring = "$user quota rem $type\n";
|
*/
|
||||||
// Write to stdin
|
foreach ($users as $user) {
|
||||||
fwrite($pipes[0], $userstring);
|
$userstring = "$user quota rem $type\n";
|
||||||
|
// Write to stdin
|
||||||
|
fwrite($pipes[0], $userstring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fclose($pipes[0]);
|
||||||
|
fclose($pipes[1]);
|
||||||
|
$return_value = proc_close($process);
|
||||||
|
}
|
||||||
|
else { // PHP 4.3>
|
||||||
|
$input = "";
|
||||||
|
foreach ($users as $user) $userstring .= "$user quota rem $type\n";
|
||||||
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
|
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||||
|
$output = '';
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$return[] = fread($pipe, 1024);
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
fclose($pipes[0]);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
$return_value = proc_close($process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,32 +437,45 @@ 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]);
|
||||||
$descriptorspec = array(
|
if (function_exists(proc_open)) {
|
||||||
0 => array("pipe", "r"), // stdin
|
// New Code, requires PHP 4.3
|
||||||
1 => array("pipe", "w"), // stout
|
$descriptorspec = array(
|
||||||
2 => array("file", "/dev/null", "a") // sterr
|
0 => array("pipe", "r"), // stdin
|
||||||
);
|
1 => array("pipe", "w"), // stout
|
||||||
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
2 => array("file", "/dev/null", "a") // sterr
|
||||||
$descriptorspec,
|
);
|
||||||
$pipes);
|
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
||||||
if (is_resource($process)) {
|
$descriptorspec,
|
||||||
/* perl-script is running
|
$pipes);
|
||||||
* $pipes[0] is writeable handle to child stdin
|
if (is_resource($process)) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
/* perl-script is running
|
||||||
* any error is send to /dev/null
|
* $pipes[0] is writeable handle to child stdin
|
||||||
*/
|
* $pipes[1] is readable handle to child stdout
|
||||||
foreach ($users as $user) {
|
* any error is send to /dev/null
|
||||||
$userstring = "$user home add\n";
|
*/
|
||||||
// Write to stdin
|
foreach ($users as $user) {
|
||||||
fwrite($pipes[0], $userstring);
|
$userstring = "$user home add\n";
|
||||||
|
// Write to stdin
|
||||||
|
fwrite($pipes[0], $userstring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fclose($pipes[0]);
|
||||||
|
fclose($pipes[1]);
|
||||||
|
$return_value = proc_close($process);
|
||||||
|
}
|
||||||
|
else { // PHP 4.3>
|
||||||
|
$input = "";
|
||||||
|
foreach ($users as $user) $userstring .= "$user home add\n";
|
||||||
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
|
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||||
|
$output = '';
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$return[] = fread($pipe, 1024);
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
fclose($pipes[0]);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
$return_value = proc_close($process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Remove Homedirectory
|
/* Remove Homedirectory
|
||||||
* 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
|
||||||
|
@ -417,29 +492,43 @@ 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]);
|
||||||
$descriptorspec = array(
|
if (function_exists(proc_open)) {
|
||||||
0 => array("pipe", "r"), // stdin
|
// New Code, requires PHP 4.3
|
||||||
1 => array("pipe", "w"), // stout
|
$descriptorspec = array(
|
||||||
2 => array("file", "/dev/null", "a") // sterr
|
0 => array("pipe", "r"), // stdin
|
||||||
);
|
1 => array("pipe", "w"), // stout
|
||||||
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
2 => array("file", "/dev/null", "a") // sterr
|
||||||
$descriptorspec,
|
);
|
||||||
$pipes);
|
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
|
||||||
if (is_resource($process)) {
|
$descriptorspec,
|
||||||
/* perl-script is running
|
$pipes);
|
||||||
* $pipes[0] is writeable handle to child stdin
|
if (is_resource($process)) {
|
||||||
* $pipes[1] is readable handle to child stdout
|
/* perl-script is running
|
||||||
* any error is send to /dev/null
|
* $pipes[0] is writeable handle to child stdin
|
||||||
*/
|
* $pipes[1] is readable handle to child stdout
|
||||||
foreach ($users as $user) {
|
* any error is send to /dev/null
|
||||||
$userstring = "$user home rem\n";
|
*/
|
||||||
// Write to stdin
|
foreach ($users as $user) {
|
||||||
fwrite($pipes[0], $userstring);
|
$userstring = "$user home rem\n";
|
||||||
|
// Write to stdin
|
||||||
|
fwrite($pipes[0], $userstring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fclose($pipes[0]);
|
||||||
|
fclose($pipes[1]);
|
||||||
|
$return_value = proc_close($process);
|
||||||
|
}
|
||||||
|
else { // PHP 4.3>
|
||||||
|
$input = "";
|
||||||
|
foreach ($users as $user) $userstring .= "$user home rem\n";
|
||||||
|
$command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite;
|
||||||
|
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||||
|
$output = '';
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$return[] = fread($pipe, 1024);
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
}
|
}
|
||||||
fclose($pipes[0]);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
$return_value = proc_close($process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -471,10 +560,10 @@ function ldapreload($type) {
|
||||||
// insert timestamp in array
|
// insert timestamp in array
|
||||||
$_SESSION['userDN'][0] = time();
|
$_SESSION['userDN'][0] = time();
|
||||||
// Search 4 values which should be cached
|
// Search 4 values which should be cached
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(),
|
$result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(),
|
||||||
'(&(objectClass=posixAccount)(!(uid=*$)))', array('cn', 'uidNumber'), 0);
|
'(&(objectClass=posixAccount)(!(uid=*$)))', array('cn', 'uidNumber'), 0);
|
||||||
// Write search result in array
|
// Write search result in array
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||||
while ($entry) {
|
while ($entry) {
|
||||||
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
||||||
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
||||||
|
@ -494,10 +583,10 @@ function ldapreload($type) {
|
||||||
// insert timestamp in array
|
// insert timestamp in array
|
||||||
$_SESSION['groupDN'][0] = time();
|
$_SESSION['groupDN'][0] = time();
|
||||||
// Search 4 values which should be cached
|
// Search 4 values which should be cached
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(),
|
$result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(),
|
||||||
'objectClass=posixGroup', array('gidNumber', 'cn'), 0);
|
'objectClass=posixGroup', array('gidNumber', 'cn'), 0);
|
||||||
// Write search result in array
|
// Write search result in array
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||||
while ($entry) {
|
while ($entry) {
|
||||||
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
||||||
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
||||||
|
@ -517,10 +606,10 @@ function ldapreload($type) {
|
||||||
// insert timestamp in array
|
// insert timestamp in array
|
||||||
$_SESSION['hostDN'][0] = time();
|
$_SESSION['hostDN'][0] = time();
|
||||||
// Search 4 values which should be cached
|
// Search 4 values which should be cached
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_HostSuffix(),
|
$result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_HostSuffix(),
|
||||||
'(&(objectClass=posixAccount)(uid=*$))', array('cn', 'uidNumber'), 0);
|
'(&(objectClass=posixAccount)(uid=*$))', array('cn', 'uidNumber'), 0);
|
||||||
// Write search result in array
|
// Write search result in array
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||||
while ($entry) {
|
while ($entry) {
|
||||||
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
|
||||||
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
|
||||||
|
|
|
@ -69,13 +69,15 @@ function createUserPDF($accounts) {
|
||||||
$info_string = str_replace('$'.$value, $sub_array, $info_string);
|
$info_string = str_replace('$'.$value, $sub_array, $info_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Split string in array
|
||||||
|
$info_array = explode("\n", $info_string);
|
||||||
$pdfFile->setFont("arial","B",12);
|
$pdfFile->setFont("arial","B",12);
|
||||||
$pdfFile->Write(5,"- " . _("User Information") . ":");
|
$pdfFile->Write(5,"- " . _("User Information") . ":");
|
||||||
$pdfFile->Ln(6);
|
$pdfFile->Ln(6);
|
||||||
$pdfFile->setFont("times","",10);
|
$pdfFile->setFont("times","",10);
|
||||||
$pdfFile->Cell(50,5,$info_string,0,1,"L",0);
|
foreach ($info_array as $info)
|
||||||
$pdfFile->Ln(9);
|
$pdfFile->Cell(50,5,$info,0,1,"L",0);
|
||||||
|
$pdfFile->Ln(6);
|
||||||
// Print Personal settings
|
// Print Personal settings
|
||||||
$pdfFile->setFont("arial","B",12);
|
$pdfFile->setFont("arial","B",12);
|
||||||
$pdfFile->Write(5,"- " . _("Personal User Infos") . ":");
|
$pdfFile->Write(5,"- " . _("Personal User Infos") . ":");
|
||||||
|
|
|
@ -94,9 +94,10 @@ else if (count($_POST)==0) {
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n".
|
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n".
|
||||||
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
||||||
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
||||||
"</head><body>\n".
|
"</head><body>\n";
|
||||||
// Display errir-messages
|
// Display errir-messages
|
||||||
StatusMessage("ERROR", _("Can not create any hosts."),_("Please create a group first."));
|
StatusMessage("ERROR", _("Can not create any hosts."),_("Please create a group first."));
|
||||||
|
echo "<a href=../lists/listhosts.php>"._("Back to hostlist")."</a>\n";
|
||||||
echo "</body></html>";
|
echo "</body></html>";
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n".
|
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n".
|
||||||
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
||||||
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
||||||
"</head><body>\n".
|
"</head><body>\n";
|
||||||
// Display errir-messages
|
// Display errir-messages
|
||||||
StatusMessage("ERROR", _("Can not create any users."),_("Please create a group first."));
|
StatusMessage("ERROR", _("Can not create any users."),_("Please create a group first."));
|
||||||
echo "<a href=../lists/listusers.php>"._("Back to userlist")."</a>\n";
|
echo "<a href=../lists/listusers.php>"._("Back to userlist")."</a>\n";
|
||||||
|
|
|
@ -44,7 +44,6 @@ $header_intern =& $_SESSION['header'];
|
||||||
$config_intern =& $_SESSION['config'];
|
$config_intern =& $_SESSION['config'];
|
||||||
$delete_dn =& $_SESSION['delete_dn'];
|
$delete_dn =& $_SESSION['delete_dn'];
|
||||||
|
|
||||||
|
|
||||||
if ($_POST['backmain']) {
|
if ($_POST['backmain']) {
|
||||||
// back to list page
|
// back to list page
|
||||||
if (isset($_SESSION['delete_dn'])) unset ($_SESSION['delete_dn']);
|
if (isset($_SESSION['delete_dn'])) unset ($_SESSION['delete_dn']);
|
||||||
|
@ -69,6 +68,8 @@ echo '</title>'."\n".
|
||||||
if ($_GET['type']) {
|
if ($_GET['type']) {
|
||||||
// $_GET['type'] is true if delete.php was called from *list.php
|
// $_GET['type'] is true if delete.php was called from *list.php
|
||||||
// Store $_GET['type'] as $_POST['type']
|
// Store $_GET['type'] as $_POST['type']
|
||||||
|
// Replace wrong chars from Session
|
||||||
|
for ($i=0; $i<count($delete_dn); $i++) $delete_dn[$i] = str_replace("_", " ", $delete_dn[$i]);
|
||||||
echo '<input name="type" type="hidden" value="'.$_GET['type'].'">';
|
echo '<input name="type" type="hidden" value="'.$_GET['type'].'">';
|
||||||
switch ($_GET['type']) {
|
switch ($_GET['type']) {
|
||||||
// Select which layout and text should be displayed
|
// Select which layout and text should be displayed
|
||||||
|
|
Loading…
Reference in New Issue