decrypt_login(); /* $towrite has the following syntax: * admin-username, admin-password, owner of homedir, 'home', operation='add' * use escapeshellarg to make exec() shell-safe */ $towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ". escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]); $userstring = implode ("\n", $commands); if (function_exists(proc_open)) { // New Code, requires PHP 4.3 $descriptorspec = array( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stout 2 => array("file", "/dev/null", "a") // sterr ); $process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite, $descriptorspec, $pipes); if (is_resource($process)) { /* perl-script is running * $pipes[0] is writeable handle to child stdin * $pipes[1] is readable handle to child stdout * any error is send to /dev/null */ // Write to stdin fwrite($pipes[0], $userstring); } fclose($pipes[0]); while (!feof($pipes[1])) { $output = fgets($pipes[1], 1024); if ($output!='') $output_array[] = $output; } fclose($pipes[1]); proc_close($process); } else { // PHP 4.3> $command = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite; $pipe = popen("echo \"$userstring\"|$command" , 'r'); while(!feof($pipe)) { //$output .= fread($pipe, 1024); $output = fgets($pipe, 1024); if ($output!='') $output_array[] = $output; } pclose($pipe); } return $output_array; } ?>