pipe_post=yes for all pre/post.sh scripts

Version 1.53


If you set a GET value of: pipe_post=yes then the POST data will be sent to the pre/post.sh scripts via stdin. DA will still try and load everything else into the ENV anyway, but long values are chopped to length limits, so if you're trying to get everything from POST, this is how you'd do it. DA will set env var: POST="stdin=true" if the above has happened, so you know to check for it. Include ?pipe_post=yes in the GET portion of the method=POST request, eg: <form action='CMD_SOMETHING?pipe_post=yes' method='POST'> Then in your script, the posted data can be read in like this: #!/usr/local/bin/php <?php $P=getenv("POST"); if ($P == "stdin=true") { echo "Got some info from stdin!!<br>"; $data = ''; $stdin = fopen('php://stdin', 'r'); while (($buffer = fgets($stdin, 1024)) !== false) { $data .= $buffer; } if (!feof($stdin)) { echo "Error: unexpected fgets() failn"; } fclose($stdin); echo "Data: ".htmlspecialchars($data); exit(1); } exit(0); ?> ===== FORCED OVERRIDE if you want the POST to always be set, regardless if a GET/POST has passed pipe_post=yes, then you can change the internal default value: force_pipe_post=(NULL) #not set in the directadmin.conf at all, to be: force_pipe_post=filemanager_pre.sh,all_pre.sh,etc. colon separated, no spaces, for a list of scripts you want to force the post to be piped through. Of course, if no moethd=POST is done, this won't kick in. ===== IMPORTANT If you do set pipe_post=true, but the script does not read any of it, you might run into a full stdin buffer.. may vary or might be fine.. just be sure to actually read the data if you're using the option, or DA may be trying to push data into a pipe with a full buffer. But if your script quits, this should close the pipe, and DA would stop sending... so in theory it should be fine. File Uploads won't show you the whole file, since that would already be stored in a temp area. You'd get something like the file0 variable pointing to to the actual location on disk, prior to it being moved by DA (should that be the instructions called, like FM file upload). ===== POST only case in some cases, like saving an edit file in the FileManager, GET cannot be used at all. An exception has been added where cases such that the custom variables passed to the .sh scripts may be a direct dump from the GET+POST already. In these cases, when the full dump happens to be passed anyway (eg: including the FileManaged edit "save"), you can include: pipe_post=yes to the POST value, and everything else should continue normally. Of course, this means you'll get pipe_post=yes passed in your POST data, but you'd just decode it anyway.

Interested to try DirectAdmin? Get a 30-day Free Trial!