Web log listing

I’am integrating hestia’s functionality into my own system and now came to step where I should list access and error logs to the end-users.

How it is done in Hestia interface? I mean, appending new lines after refresh of url. For example:

https://server.domain.tld:1166/list/web-log/?domain=domain2.tld&type=access

I can’t find any javascript example which handles this, so it should be PHP…

PHP file used by Hestia is this:
/usr/local/hestia/web/list/web-log/index.php

And basically it executes commands v-list-web-domain-accesslog and v-list-web-domain-errorlog.

1 Like

But when he calls v-list-web-domain-accesslog he gets the number 2

Sorry but don’t know what you mean.

v-list-web-domain-accesslog user domain 200 json

And you will get a lift of the last 200 lines of the access logs

I have this error

string(34) "Error: invalid ttl format :: json "

Command format is:

v-list-web-domain-accesslog USER DOMAIN [LINES] [FORMAT]

So you can’t use

v-list-web-domain-accesslog USER DOMAIN json

You must specify the number of lines (example with 200):

v-list-web-domain-accesslog USER DOMAIN 200 json

This is what my reference looks like in PHP

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,  http_build_query(array(
     'user' => $user_name_admin_hestiacp,
    'password' => $user_password_admin_hestiacp
    'returncode' => 'no',
    'cmd' => 'v-list-web-domain-accesslog',
    'arg1' => $user_host,
    'arg2' => $domens,
    'arg3' => 'json'
)));
$answer = curl_exec($curl);


// Parse JSON output
return json_decode($answer, true);

And it’s not written anywhere in the documentation

CLI Reference

I disabled JSON, and it works.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,  http_build_query(array(
     'user' => $user_name_admin_hestiacp,
    'password' => $user_password_admin_hestiacp
    'returncode' => 'no',
    'cmd' => 'v-list-web-domain-accesslog',
    'arg1' => $user_host,
    'arg2' => $domens,
    //'arg3' => 'json'
)));
$answer = curl_exec($curl);


// Parse JSON output
echo $answer;

Yes, because by default it uses 70 lines but if you want to use the format you must specify the number of lines.

Leaving it empty as in ‘’ should work aswell…

It doesn’t work because it is defined as ttl=${3-70} instead of ttl=${3:-70} so an empty argument doesn’t work in this command :wink:

1 Like

I don’t want it to be like in the hestiacp panel

I don’t know what you want nor what you are trying to do, I’m only explaining what are the arguments the command needs.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.