0) { $ip = substr($ip, strrpos($ip, ":") + 1); // Strip IPv4 Compatibility notation } return $ip; } /** * Create a history log using 'v-log-action' script. * * @param string $message The message for log. * @param string $category A category for log. Ex: Auth, Firewall, API... * @param string $level Info|Warning|Error. * @param string $user A username for save in the user history ou 'system' to save in Hestia history. * @return int The script result code. */ function hst_add_history_log($message, $category = "System", $level = "Info", $user = "system") { //$message = ucfirst($message); //$message = str_replace("'", "`", $message); $category = ucfirst(strtolower($category)); $level = ucfirst(strtolower($level)); $command_args = quoteshellarg($user) . " " . quoteshellarg($level) . " " . quoteshellarg($category) . " " . quoteshellarg($message); exec(HESTIA_CMD . "v-log-action " . $command_args, $output, $return_var); unset($output); return $return_var; } function get_hostname() { $badValues = [ false, null, 0, "", "localhost", "127.0.0.1", "::1", "0000:0000:0000:0000:0000:0000:0000:0001", ]; $ret = gethostname(); if (in_array($ret, $badValues, true)) { throw new Exception("gethostname() failed"); } $ret2 = gethostbyname($ret); if (in_array($ret2, $badValues, true)) { return $ret; } $ret3 = gethostbyaddr($ret2); if (in_array($ret3, $badValues, true)) { return $ret2; } return $ret3; } function display_title($tab) { $array1 = ["{{page}}", "{{hostname}}", "{{ip}}", "{{appname}}"]; $array2 = [$tab, get_hostname(), $_SERVER["REMOTE_ADDR"], $_SESSION["APP_NAME"]]; return str_replace($array1, $array2, $_SESSION["TITLE"]); }