getenv(...) returns false in /CMD_LICENSE

cyberda

Verified User
Joined
Oct 20, 2020
Messages
21
Location
Spain
Hello:

I try to "include" my functions file into the /CMD_LICENSE page, but when I do the getenv("DOCUMENT_ROOT") to locate the file, it returns empty. It works well in the other pages, what changed in the CMD_LICENSE page?

Btw, getenv("REQUEST_URI") doesn't work either.

Thank you.
 
Thanks for reporting this issue. Page /CMD_LICENSE is treated differently than all other pages - it uses new template rendering engine.

Your report helped us to uncover that new engine behaves differently from the old one. An update will be released with DA 1.643, it should have the same environment variables set as in other pages. You can test it out already if you would switch to the alpha release channel.
 
Hello @fln
It happens the same with HTM_TEMPLATE (I mean, for example, the compression confirmation page from the filemanager).

getenv() returns:
array(0) { }

Regards.
 
Hello again @fln

It happens again.

var_dump(getenv(.....)) or $_ENV are empty while loading /CMD_LICENSE.

Regards.
 
Could you give me more details on how you are dumping variables. I tried to reproduce the issue but it seems to be working as expected.

I have added the following snippet to the enhanced skin admin/license.html file:

Code:
...
</table>
|$php
<?
var_dump(getenv());
DONE|
|HTM_ADMIN_BOTTOM|

Visiting the page I can see environment variables printed out as:

Code:
array(31) {
  ["LANGUAGE"]=>  string(2) "en"
  ["USER"]=>  string(5) "admin"
  ["LOGIN_KEY_NAME"]=>  string(8) "..."
  ["REMOTE_ADDR"]=>  string(14) "1.1.1.1"
  ["SESSION_ID"]=>  string(39) "..."
  ["QUERY_STRING"]=>  string(0) ""
  ["HOME"]=>  string(11) "/home/admin"
  ["POST"]=>  string(0) ""
  ["DOCUMENT_ROOT"]=>  string(42) "/usr/local/directadmin/data/skins/enhanced"
  ["SESSION_SELECTED_DOMAIN"]=>  string(0) ""
  ["SSL"]=>  string(1) "1"
  ["IS_LOGIN_AS"]=>  string(1) "0"
  ["HTTP_HOST"]=>  string(22) "server.example.net"
  ["JOURNAL_STREAM"]=>  string(10) "..."
  ["REQUEST_URI"]=>  string(12) "/CMD_LICENSE"
  ["SERVER_SOFTWARE"]=>  string(11) "DirectAdmin"
  ["IS_LOGIN_KEY"]=>  string(1) "1"
  ["USERNAME"]=>  string(5) "admin"
  ["SESSION_KEY"]=>  string(39) "..."
  ["HTTP_COOKIE"]=>  string(152) "..."
  ["PATH"]=>  string(60) "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  ["INVOCATION_ID"]=>  string(32) "..."
  ["LANG"]=>  string(11) "en_US.UTF-8"
  ["REDIRECT_STATUS"]=>  string(3) "CGI"
  ["REQUEST_METHOD"]=>  string(3) "GET"
  ["SKIN_NAME"]=>  string(8) "enhanced"
  ["DA_VERSION"]=>  string(5) "1.646"
  ["PWD"]=>  string(22) "/usr/local/directadmin"
  ["SERVER_PORT"]=>  string(4) "2222"
  ["SCRIPT_NAME"]=>  string(12) "/CMD_LICENSE"
  ["SERVER_NAME"]=>  string(22) "server.example.net"
}
 
Thank you for the answer @fln

Tested (admin/license.html):
|$php
<?
var_dump(getenv("SERVER_ADDR"));
DONE|

Prints:
bool(false)

$_ENV is empty.

PHP 7.0
Directadmin version v1.646

-- Update

$_SERVER["REMOTE_ADDR"] returns false too, so I'm using gethostbyname(...)

Regards.
 
Last edited:
Back
Top