enable $_get $_post php in directadmin

How to use $_GET and $_POST in a plugin​



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 not there by default with the command line version.

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

php

//make code look like CLI for $_GET and $_POST$_GET = Array();$QUERY_STRING=getenv('QUERY_STRING');if ($QUERY_STRING != ""){ parse_str(html_entity_decode($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(html_entity_decode($POST_STRING), $post_array); foreach ($post_array as $key => $value) { $_POST[urldecode($key)] = urldecode($value); }}
 
Last edited:
Back
Top