Return All WebServer current Log WebServer in Html format

@param bool $clean true if messages needs to be cleaned after reading

@return string
514935
public function getHtmlLog($clean = false)
    {
        $html = null;
        //====================================================================//
        // Read All Messages as Html
        $html .= $this->getHtml($this->err, 'Errors', '#FF3300');
        $html .= $this->getHtml($this->war, 'Warning', '#FF9933');
        $html .= $this->getHtml($this->msg, 'Messages', '#006600');
        $html .= $this->getHtml($this->deb, 'Debug', '#003399');
        //====================================================================//
        // Clear Log Buffer If Requiered
        if ($clean) {
            $this->cleanLog();
        }

        return $html;
    }
940840
public function info(bool $full = false): string
    {
        $return = sprintf('%s: id=%s(%s)', $this->role, $this->id, $this->name);
        if ($full) {
            foreach ($this->permissions as $uri => $rules) {
                $return .= sprintf("\n uri(%s %s)", $uri, implode(',', $rules));
            }
        }

        return $return;
    }
1160909
public function getLinks($all = false)
    {
        $links = [];

        $this->getLinksByTagAttribute("link", "href", $links);
        $this->getLinksByTagAttribute("a", "href", $links);
        $this->getLinksByTagAttribute("script", "src", $links);
        $this->getLinksByTagAttribute("iframe", "src", $links);
        $this->getLinksByTagAttribute("img", "src", $links);

        //get all string started with http
        $regexUrl = '/[">\s]+((http|https|ftp|ftps)\:\/\/(.*?))["<\s]+/';
        $urls     = null;
        if (preg_match_all($regexUrl, $this->html, $urls) > 0) {
            $matches = $urls[1];
            foreach ($matches as $url) {
                if (filter_var($url, FILTER_VALIDATE_URL)) {
                    $links[$url] = $url;
                }
            }
        }

        if ($all) {
            //get all params which can be a url
            $regexParam = '/["](.*?)["]/';
            $params     = [];
            if (preg_match_all($regexParam, $this->html, $params) > 0) {
                $urls = $params[1];
                foreach ($urls as $url) {
                    $url = trim($url);
                    if ((strpbrk($url, "/.") !== false) && (strpbrk($url, " ") === false)) {
                        $links[$url] = $url;
                    }
                }
            }
        }

        foreach ($links as $link) {
            $url = parse_url($link);
            if (!((isset($url['host']) && isset($url['scheme'])) || (isset($url['path'])))) {
                unset($links[$link]);
            }
        }

        return $links;
    }
809656
def html_for_check(self, check) -> str:
        """"""
        check["logs"].sort(key=lambda c: LOGLEVELS.index(c["status"]))
        logs = "<ul>" + "".join([self.log_html(log) for log in check["logs"]]) + "</ul>"
        return logs
844419
public function server($index, $xss_clean = true)
    {
        if ($xss_clean) {
            return XssClean::getXssClean()->xss_clean($this->request->server[$index]??'');
        } else {
            return $this->request->server[$index]??'';
        }
    }
513991
public function getWebPath($trim = false)
    {
        if ($trim) {
            return trim($this->web_path, FileManager::DS);
        } else {
            return $this->web_path;
        }
    }
373220
protected function parseLog($raw)
    {
        $logs = preg_split('/\[(\d{4}(?:-\d{2}){2} \d{2}(?::\d{2}){2})\] (\w+)\.(\w+):((?:(?!{"exception").)*)?/', trim($raw), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

        foreach ($logs as $index => $log) {
            if (preg_match('/^\d{4}/', $log)) {
                break;
            } else {
                unset($logs[$index]);
            }
        }

        if (empty($logs)) {
            return [];
        }

        $parsed = [];

        foreach (array_chunk($logs, 5) as $log) {
            $parsed[] = [
                'time'  => $log[0] ?? '',
                'env'   => $log[1] ?? '',
                'level' => $log[2] ?? '',
                'info'  => $log[3] ?? '',
                'trace' => trim($log[4] ?? ''),
            ];
        }

        unset($logs);

        rsort($parsed);

        return $parsed;
    }
1301575
protected function currentUrlSsl()
    {
        if (isset(static::$static[__FUNCTION__])) {
            return static::$static[__FUNCTION__];
        }
        if (!empty($_SERVER['SERVER_PORT'])) {
            if ((int) $_SERVER['SERVER_PORT'] === 443) {
                return static::$static[__FUNCTION__] = true;
            }
        }
        if (!empty($_SERVER['HTTPS'])) {
            if (filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) {
                return static::$static[__FUNCTION__] = true;
            }
        }
        if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
            if (strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0) {
                return static::$static[__FUNCTION__] = true;
            }
        }
        return static::$static[__FUNCTION__] = false;
    }
1007537
public function getAllContents()
    {
        $sLog    = '';
        $sFormat = "----------------------------------------------------------------------\n" .
                   "%s\n" .
                   "----------------------------------------------------------------------\n\n" .
                   "%s\n\n";

        $sLogDirectoryPath = $this->getErrorLogPath();
        $hDir              = @opendir( $sLogDirectoryPath );

        if ( !empty( $hDir ) ) {
            while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
                $sLog .= $this->_getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat );
            }
        }

        return $sLog;
    }
592926
public function clean($domain)
    {
        $domain = trim($domain);
        $domain = preg_replace('#^https?://#', '', $domain);
        if (substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);

        return $domain;
    }
1119320
public function getRawLog($clean = false)
    {
        $raw = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
        if ($this->err) {
            $raw->err = $this->err;
        }
        if ($this->war) {
            $raw->war = $this->war;
        }
        if ($this->msg) {
            $raw->msg = $this->msg;
        }
        if ($this->deb) {
            $raw->deb = $this->deb;
        }
        if ($clean) {
            $this->cleanLog();
        }

        return $raw;
    }
1162684
function connect($clean = true)
    {

        // Don't do anything, if server address is not set
        if(!$this->serverAddress) {
            return false;
        }

        // Is encryption enabled?
        if($this->connMethod!="tcp") {
            $socketContextOptions = [ "ssl" => [] ];
            $socketContextOptions["ssl"]["verify_peer_name"] = $this->verifyPeerName;

            if($this->caFile) {
                $socketContextOptions["ssl"]["cafile"]=$this->caFile;
            }

            if($this->clientCrt) {
                $socketContextOptions["ssl"]["local_cert"]=$this->clientCrt;
            }

            if ($this->clientCrt && $this->clientKey) {
                $socketContextOptions["ssl"]["local_pk"]=$this->clientKey;
            }

            $socketContext = stream_context_create($socketContextOptions);
            $host = $this->connMethod . "://" . $this->serverAddress . ":" . $this->serverPort;

            $this->socket = stream_socket_client(
                $host, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $socketContext);

            $this->debugMessage("Connecting to: ".$host);
        } else {
            $host = $this->connMethod . "://" . $this->serverAddress . ":" . $this->serverPort;
            $this->socket = stream_socket_client(
                $host, $errno, $errstr, 60, STREAM_CLIENT_CONNECT );
            $this->debugMessage("Connecting to: ".$host);
        }

        //
        if(!$this->socket) {
            $this->socket = null;
            $this->debugMessage("Connection failed.. $errno , $errstr");
            return false;
        }

        //
        stream_set_timeout($this->socket, 10);
        stream_set_blocking($this->socket, false);

        $bytes = 0;
        $buffer = "";

        // ------------------------------------
        // Calculate connect flags

        $var = $clean?2:0;
/*
        if($this->will != NULL)
        {
            $var += 4;                              // Set will flag
            $var += ($this->will['qos'] << 3);      // Set will qos

            if($this->will['retain'])
                $var += 32;                     // Set will retain
        }
*/

        if($this->authPass != NULL) {
            $var += 64;
        }

        if($this->authUser != NULL) {
            $var += 128;
        }

        // ------------------------------------
        // Create CONNECT packet (for MQTT 3.1.1 protocol)

        $buffer .= $this->convertString("MQTT", $bytes);

        $buffer .= chr(0x04);   // Protocol level
        $bytes++;

        $buffer .= chr($var);   // Connect flags
        $bytes++;

        $buffer .= chr($this->keepAlive >> 8);  // Keepalive (MSB)
        $bytes++;

        $buffer .= chr($this->keepAlive & 0xff);    // Keepalive (LSB)
        $bytes++;

        $buffer .= $this->convertString($this->clientID,$bytes);

        //Adding will to payload
        /*
        if($this->will != NULL){
            $buffer .= $this->strwritestring($this->will['topic'],$bytes);
            $buffer .= $this->strwritestring($this->will['content'],$bytes);
        }
        */

        if($this->authUser) {
            $buffer .= $this->convertString($this->authUser,$bytes);
        }

        if($this->authPass) {
            $buffer .= $this->convertString($this->authPass,$bytes);
        }

        $header = $this->createHeader( 0x10 , $bytes );
        fwrite($this->socket, $header, strlen($header));
        fwrite($this->socket, $buffer);

        // Wait for CONNACK packet
        $string = $this->readBytes(4, false);
        if(strlen($string)!=4) {
            $this->debugMessage("Connection failed! Server gave unexpected response (".strlen($string)." bytes).");
            return false;
        }

        if(ord($string{0}) == 0x20 && $string{3} == chr(0)) {
            $this->debugMessage("Connected to MQTT");
        } else {
            $msg = sprintf("Connection failed! Error: 0x%02x 0x%02x",
                ord($string{0}),ord($string{3}) );
            $this->debugMessage($msg);
            return false;
        }

        $this->timeSincePingReq = time();
        $this->timeSincePingResp = time();

        return true;
    }
929362
public static function getLog($empty = false)
    {
        $log = self::$log;
        if ($empty) {
            self::emptyLog();
        }
        return $log;
    }
917715
public function readAll($res = 'out')
    {
        $str = '';
        $this->debugStatus();
        $this->debug('reading all output');
        //stream_set_blocking($this->pipes[$res],0);
        $str = stream_get_contents($this->pipes[$res]);
        $this->close($res);
        if (substr($str, -1) != "\n") {
            $str .= "\n";
        }

        return $str;
    }
988550
public static function is_cleanPath($path, $clean = false, $regex = '!_-\w\/\\\ ')
    {
        if ($clean === true) {
            $path = self::get_directPath($path);
        }
        if (preg_match('/[^' . $regex . ']/', $path)) {
            return false;
        }
        return $path;
    }
661145
protected function getServerInfo($running = true)
    {
        if (!isset($this->serverInfo)) {
            $this->serverInfo = [];
            // @todo move this to State service (in a new major version)
            $filename = $this->config()->getWritableUserDir() . '/local-servers.json';
            if (file_exists($filename)) {
                $this->serverInfo = (array) json_decode(file_get_contents($filename), true);
            }
        }

        if ($running) {
            return array_filter($this->serverInfo, function ($server) {
                if ($this->isProcessDead($server['pid'])) {
                    $this->stopServer($server['address']);
                    return false;
                }

                return true;
            });
        }

        return $this->serverInfo;
    }
928423
public function protocol($version = false) : string {
      if ($version === false) {
        $protocol = 'http';
        if ($this->server()->get('HTTPS')) {
          $protocol = 'https';
        }
        
        return $protocol;
      }
      
      return $this->server()->get('SERVER_PROTOCOL');
    }