Update of /cvsroot/serverfilters
In directory sc8-pr-cvs1:/tmp/cvs-serv29849
Modified Files:
functions.php backend.php
Log Message:
filtercmd no longer uses temporary files.
Index: backend.php
===================================================================
RCS file: /cvsroot/serverfilters/backend.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** backend.php 13 Dec 2003 22:03:40 -0000 1.7
--- backend.php 25 Dec 2003 02:14:30 -0000 1.8
***************
*** 24,28 ****
$localfile = "/tmp/$FILTERFILE.$username";
if (local_file_exists($file)) {
! $err_code = invoke_filtercmd("getrc $file $localfile");
if ($err_code != 0) exit("filtercmd returned $err_code");
} else
--- 24,28 ----
$localfile = "/tmp/$FILTERFILE.$username";
if (local_file_exists($file)) {
! $err_code = invoke_filtercmd("getrc $file", "", $localfile);
if ($err_code != 0) exit("filtercmd returned $err_code");
} else
***************
*** 39,56 ****
}
! function invoke_filtercmd($argstring) {
global $username;
$command = escapeshellcmd("../plugins/serversidefilter/script/filtercmd $argstring");
! //DEBUG echo("command: $command");
$pipe = popen($command, "w");
! if (!$pipe) exit("Could not run $command");
$password = get_password();
! fwrite($pipe, "$username $password\n");
$result = pclose($pipe);
// simulate WEXITSTATUS($result) -- this is not portable
$result = $result / 256;
! //DEBUG
! if ($result) echo("$command -> $result<br>\n");
return $result;
--- 39,67 ----
}
! function invoke_filtercmd($argstring, $inputfile, $outputfile) {
global $username;
$command = escapeshellcmd("../plugins/serversidefilter/script/filtercmd $argstring");
! if ($outputfile) {
! $command .= " >$outputfile ";
! }
!
$pipe = popen($command, "w");
! if (!pipe) exit("Could not run $command");
$password = get_password();
! fwrite($pipe, "$username\n$password\n");
! if ($inputfile) {
! // copy the file to the pipe
! $handle = fopen($inputfile, "r");
! while ($data = fread($handle, 8192)) {
! fwrite($pipe, $data);
! }
! fclose($handle);
! }
$result = pclose($pipe);
// simulate WEXITSTATUS($result) -- this is not portable
$result = $result / 256;
! //DEBUG: uncomment to help debug problems
! //if ($result) echo("$command -> $result<br>\n");
return $result;
***************
*** 68,72 ****
function local_file_exists($file) {
! $exists = invoke_filtercmd("rcexists $file");
if ($exists == 0)
return true;
--- 79,83 ----
function local_file_exists($file) {
! $exists = invoke_filtercmd("rcexists $file", "", "");
if ($exists == 0)
return true;
***************
*** 93,97 ****
$user = $username;
! $err_code = invoke_filtercmd("putrc $user $file $localfile");
}
--- 104,108 ----
$user = $username;
! $err_code = invoke_filtercmd("putrc $user $file", $localfile, "");
}
|