changed code to communicate with lamdaemon.pl
to support < PHP 4.3
This commit is contained in:
parent
78145c6288
commit
55e8c117ed
|
@ -210,6 +210,8 @@ 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
|
||||||
*/
|
*/
|
||||||
|
if (function_exists(proc_open)) {
|
||||||
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin
|
0 => array("pipe", "r"), // stdin
|
||||||
1 => array("pipe", "w"), // stout
|
1 => array("pipe", "w"), // stout
|
||||||
|
@ -238,6 +240,19 @@ function getquotas($type,$users=array('+')) {
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
$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');
|
||||||
|
$output = '';
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$output .= fread($pipe, 1024);
|
||||||
|
if ($output!='') $vals5[] = $output;
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
|
}
|
||||||
/* $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,6 +261,7 @@ 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
|
||||||
*/
|
*/
|
||||||
|
if (is_array($vals5))
|
||||||
foreach ($vals5 as $vals3) {
|
foreach ($vals5 as $vals3) {
|
||||||
$vals = explode(':', $vals3);
|
$vals = explode(':', $vals3);
|
||||||
for ($i=0; $i<sizeof($vals)-1; $i++) {
|
for ($i=0; $i<sizeof($vals)-1; $i++) {
|
||||||
|
@ -278,6 +294,8 @@ 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]);
|
||||||
|
if (function_exists(proc_open)) {
|
||||||
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin
|
0 => array("pipe", "r"), // stdin
|
||||||
1 => array("pipe", "w"), // stout
|
1 => array("pipe", "w"), // stout
|
||||||
|
@ -319,6 +337,36 @@ function setquotas($values2,$values2_old=false) {
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
$return_value = proc_close($process);
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
$pipe = popen("echo \"$input\"|$command" , 'r');
|
||||||
|
while(!feof($pipe)) {
|
||||||
|
$return[] = fread($pipe, 1024);
|
||||||
|
}
|
||||||
|
pclose($pipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Whis function will remove the quotas from the specified user.
|
/* Whis function will remove the quotas from the specified user.
|
||||||
|
@ -335,6 +383,8 @@ 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 (function_exists(proc_open)) {
|
||||||
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin
|
0 => array("pipe", "r"), // stdin
|
||||||
1 => array("pipe", "w"), // stout
|
1 => array("pipe", "w"), // stout
|
||||||
|
@ -359,6 +409,18 @@ function remquotas($users, $type) {
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create Homedirectory
|
/* Create Homedirectory
|
||||||
|
@ -375,6 +437,8 @@ 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 (function_exists(proc_open)) {
|
||||||
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin
|
0 => array("pipe", "r"), // stdin
|
||||||
1 => array("pipe", "w"), // stout
|
1 => array("pipe", "w"), // stout
|
||||||
|
@ -399,7 +463,18 @@ function addhomedir($users) {
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 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.
|
||||||
|
@ -417,6 +492,8 @@ 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 (function_exists(proc_open)) {
|
||||||
|
// New Code, requires PHP 4.3
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin
|
0 => array("pipe", "r"), // stdin
|
||||||
1 => array("pipe", "w"), // stout
|
1 => array("pipe", "w"), // stout
|
||||||
|
@ -441,6 +518,18 @@ function remhomedir($users) {
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$return_value = proc_close($process);
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function maintains the ldap-cache which is used to reduce ldap requests
|
/* This function maintains the ldap-cache which is used to reduce ldap requests
|
||||||
|
@ -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