I need the $_GET and $_POST arrays in my plugin

Note that the DirectAdmin plugin system can use php, however the php used is /usr/local/bin/php, and not the same php used by apache. The differences are that many of the default/loaded variables made available to php coders are no there by default with the command line version.

This is a basic php code to convert the environmentable variables that DA does pass, into the $_GET and $_POST arrays that you're used to working with through apache:

//make code look like CLI for $_GET and $_POST
$_GET = Array();
$QUERY_STRING=getenv('QUERY_STRING');
if ($QUERY_STRING != "")
{
     parse_str(unhtmlentities($QUERY_STRING), $get_array);
     foreach ($get_array as $key => $value)
     {
         $_GET[urldecode($key)] = urldecode($value);
     }
}

$_POST = Array();
$POST_STRING=getenv('POST');
if ($POST_STRING != "")
{
     parse_str(unhtmlentities($POST_STRING), $post_array);
     foreach ($post_array as $key => $value)
     {
         $_POST[urldecode($key)] = urldecode($value);
     }
}
 
plugins/arrays.txt · Last modified: 2010/02/22 09:25 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki