Parse server hardware.

@access protected
167197
protected function serverInfoHardware()
    {
        $linfo = $this->linfo->getParser();

        $CPUs = $this->ifExists($linfo->getCPU());
        $cpu = $this->getCPUString($CPUs);
        $cpu_count = count($CPUs);

        $model = $this->ifExists($linfo->getModel());
        $virtualization = $this->getVirtualizationString(
            $this->ifExists($linfo->getVirtualization())
        );

        $memory = $this->ifExists($linfo->getRam());
        $ram = [
            'total' => (int) $this->ifExists($memory['total']),
            'free' => (int) $this->ifExists($memory['free']),
        ];
        $swap = [
            'total' => (int) $this->ifExists($memory['swapTotal']),
            'free' => (int) $this->ifExists($memory['swapFree']),
        ];

        $disk = $this->getDiskSpace($linfo->getMounts());

        $this->results['server']['hardware'] = compact(
            'cpu', 'cpu_count', 'model', 'virtualization', 'ram', 'swap', 'disk'
        );

        return $this;
    }
137458
def system_info(data):
    '''
    
    '''
    if not data:
        return {}
    info = {
        'software': _parse_software(data),
        'hardware': _parse_hardware(data),
        'plugins': _parse_plugins(data),
    }
    return {'nxos': info}
73263
private static function parseQuery() : array
    {
        /*
         * Parse the query string. We need to do this ourself, so that we get access
         * to the raw (urlencoded) values. This is required because different software
         * can urlencode to different values.
         */
        $data = [];
        $relayState = '';
        $sigAlg = '';
        $sigQuery = '';
        foreach (explode('&', $_SERVER['QUERY_STRING']) as $e) {
            $tmp = explode('=', $e, 2);
            $name = $tmp[0];
            if (count($tmp) === 2) {
                $value = $tmp[1];
            } else {
                /* No value for this parameter. */
                $value = '';
            }
            $name = urldecode($name);
            $data[$name] = urldecode($value);

            switch ($name) {
                case 'SAMLRequest':
                case 'SAMLResponse':
                    $sigQuery = $name.'='.$value;
                    break;
                case 'RelayState':
                    $relayState = '&RelayState='.$value;
                    break;
                case 'SigAlg':
                    $sigAlg = '&SigAlg='.$value;
                    break;
            }
        }

        $data['SignedQuery'] = $sigQuery.$relayState.$sigAlg;

        return $data;
    }
227824
def hardware_version(self):
        """"""

        hardware_string = self.hardware_string

        if not isinstance(hardware_string, bytes):
            hardware_string = self.hardware_string.encode('utf-8')

        if len(hardware_string) > 10:
            self._logger.warn("Truncating hardware string that was longer than 10 bytes: %s", self.hardware_string)

        if len(hardware_string) < 10:
            hardware_string += b'\0'*(10 - len(hardware_string))

        return [hardware_string]
1319768
private static function deviceParser() {

        // build the obj that will be returned
        $deviceObj = new \stdClass();

        // run the regexes to match things up
        $deviceRegexes = self::$regexes['device_parsers'];
        foreach ($deviceRegexes as $deviceRegex) {
            if (preg_match("/".str_replace("/","\/",$deviceRegex['regex'])."/i",self::$ua,$matches)) {

                // Make sure device matches are null
                // Device Name, Major and Minor defaults
                if (!isset($matches[1])) { $matches[1] = null; }
                    if (!isset($matches[2])) { $matches[2] = null; }
                        if (!isset($matches[3])) { $matches[3] = null; }

                            // basic properties
                            $deviceObj->deviceMajor  = isset($deviceRegex['device_v1_replacement']) ? $deviceRegex['device_v1_replacement'] : $matches[2];
                $deviceObj->deviceMinor  = isset($deviceRegex['device_v2_replacement']) ? $deviceRegex['device_v2_replacement'] : $matches[3];
                $deviceObj->device       = isset($deviceRegex['device_replacement']) ? str_replace("$1",$matches[1],$deviceRegex['device_replacement']) : str_replace("_"," ",$matches[1]);

                // device version?
                $deviceObj->deviceVersion = isset($deviceObj->deviceMajor) ? $deviceObj->deviceMajor : "";
                $deviceObj->deviceVersion = isset($deviceObj->deviceMinor) ? $deviceObj->deviceVersion.'.'.$deviceObj->deviceMinor : $deviceObj->deviceVersion;

                // prettify
                $deviceObj->deviceFull = $deviceObj->device." ".$deviceObj->deviceVersion;

                // check to see if this is a mobile device
                // this isn't really needed because if it matches a mobile browser it'll automatically mark it as a mobile device
                $deviceObj->isMobileDevice = false;
                $mobileDevices  = array("iPhone","iPod","iPad","HTC","Kindle","Lumia","Amoi","Asus","Bird","Dell","DoCoMo","Huawei","i-mate","Kyocera",
                    "Lenovo","LG","Kin","Motorola","Philips","Samsung","Softbank","Palm","HP ","Generic Feature Phone","Generic Smartphone",
                    "Nintendo DSi","Nintendo 3DS","PlayStation Vita");
                foreach($mobileDevices as $mobileDevice) {
                    if (stristr($deviceObj->device, $mobileDevice)) {
                        $deviceObj->isMobileDevice = true;
                        break;
                    }
                }

                // check to see if this is a tablet (not perfect)
                $deviceObj->isTablet = false;
                $tablets = array("Kindle","iPad","Playbook","TouchPad","Dell Streak","Galaxy Tab","Xoom");
                foreach($tablets as $tablet) {
                    if (stristr($deviceObj->device, $tablet)) {
                        $deviceObj->isTablet = true;
                        break;
                    }
                }

                return $deviceObj;
            }
        }
        return false;
    }
950634
private void parseServers(List<String> servers){
        if(servers != null && servers.size() > 0){
            this.servers = new ArrayList<InetSocketAddress>();
            for(String server : servers){
                String[] ss = server.split(":");
                if(ss.length == 2){
                    String host = ss[0];
                    int port = 0;
                    try{
                        port = Integer.valueOf(ss[1]);
                    } catch(NumberFormatException e){
                        // do nothing.
                    }
                    if(validateServer(host, port)){
                        this.servers.add(InetSocketAddress.createUnresolved(host, port));
                    }
                }
            }
        }
    }
487739
function getServerParams()
    {
        if ($this->_server === null) {
            $params = PhpServer::_($this->httpMessage)->getServer();
            $this->_server = \Poirot\Std\cast($params)->toArray();
        }

        return $this->_server;
    }
885003
def parse_show_server_lines(server, lines)
      s = Server.new(server)
      lines.each do |l|
        key, value = l.gsub("\t","").split(": ")
        case key.chomp
        when "active"
          s.active = value.to_bool
        when "ssh_command"
          s.ssh_cmd = value
        when "conninfo"
          s.conn_info = value
        when "backup_directory"
          s.backup_dir = value
        when "basebackups_directory"
          s.base_backups_dir = value
        when "wals_directory"
          s.wals_dir = value
        when "server_txt_version"
          s.pg_version = value
        end
      end
      return s
    end
559408
private function parseSysLogData()
    {
        $file = '/var/log/syslog';
        if (!is_file($file) || !is_readable($file)) {
            return [];
        }
        $devices = [];
        foreach (Common::getLines($file) as $line) {
            if (preg_match('/\w+\s*\d+ \d{2}:\d{2}:\d{2} \w+ hddtemp\[\d+\]: (.+): (.+): (\d+) ([CF])/i', trim($line), $match) == 1) {
                // Replace current record of dev with updated temp
                $devices[$match[1]] = array($match[2], $match[3], $match[4]);
            }
        }
        $return = [];
        foreach ($devices as $dev => $stat) {
            $return[] = array(
                'path' => $dev,
                'name' => $stat[0],
                'temp' => $stat[1],
                'unit' => strtoupper($stat[2]),
            );
        }

        return $return;
    }
1143845
protected function parse()
    {
        $json = $this->httpResponse->json();

        $this->services = [];

        foreach ($json['objects'] as $serviceJson) {
            $this->services[] = $this->parseService($serviceJson);
        }
    }
567563
private function parse()
    {
        $opts = $this->result->options;
        $commandName = $this->result->command_name;
        $command = null;
        $optionSet = $argumentSet = false;

        // special treatment for -h --help main command options
        if ($opts['help'] === true) {
            $commandName = 'help';
        }

        if ($commandName) {
            $configFile = $this->paths['configs'] . 'commands/' . $commandName . '.yml';
            $command = new Command($configFile);
        }

        // check if any option is set
        // basically check for --version -v --help -h options
        foreach ($opts as $name => $value) {
            if ($value === true) {
                $optionSet = true;
                break;
            }
        }

        // fire up subcommand
        if (isset($command['callback'])) {
            $this->invoke($command['callback'], $command);
        }

        if ($commandName === false && $optionSet === false && $argumentSet === false) {
            $this->parser->outputter->stdout("Type 'phrozn help' for usage.\n");
        }
    }
1337914
protected function parseConnectionInformation()
    {
        if ( ( $info = @parse_url( $this->dsn ) ) === false )
        {
            fwrite( $this->stderr, "Could not parse provided DSN: {$this->dsn}\n" );
            return false;
        }

        foreach ( $info as $key => $value )
        {
            if ( array_key_exists( $key, $this->connectionInfo ) )
            {
                $this->connectionInfo[$key] = $value;
            }
        }

        if ( isset( $this->options['username'] ) )
        {
            $this->connectionInfo['user'] = $this->options['username'];
        }

        if ( isset( $this->options['password'] ) )
        {
            $this->connectionInfo['pass'] = $this->options['password'];
        }

        return true;
    }
586299
function parseServerType(ismaster) {
  if (!ismaster || !ismaster.ok) {
    return ServerType.Unknown;
  }

  if (ismaster.isreplicaset) {
    return ServerType.RSGhost;
  }

  if (ismaster.msg && ismaster.msg === 'isdbgrid') {
    return ServerType.Mongos;
  }

  if (ismaster.setName) {
    if (ismaster.hidden) {
      return ServerType.RSOther;
    } else if (ismaster.ismaster) {
      return ServerType.RSPrimary;
    } else if (ismaster.secondary) {
      return ServerType.RSSecondary;
    } else if (ismaster.arbiterOnly) {
      return ServerType.RSArbiter;
    } else {
      return ServerType.RSOther;
    }
  }

  return ServerType.Standalone;
}
1140930
private function parseSSL()
    {
        if($this->request->getAttribute('isVerifyCA', false))
        {
            $this->settings['ssl_verify_peer'] = true;
            $caCert = $this->request->getAttribute('caCert');
            if(null !== $caCert)
            {
                $this->settings['ssl_cafile'] = $caCert;
            }
        }
        else
        {
            $this->settings['ssl_verify_peer'] = false;
        }
        $certPath = $this->request->getAttribute('certPath', '');
        if('' !== $certPath)
        {
            $this->settings['ssl_cert_file'] = $certPath;
        }
        $keyPath = $this->request->getAttribute('keyPath' , '');
        if('' !== $keyPath)
        {
            $this->settings['ssl_key_file'] = $keyPath;
        }
    }
175345
private function parseComposerLoader(): void
    {
        // get composer autoload map
        $map = $this->loader->getPrefixes();
        if (Any::isArray($map)) {
            // get all available apps root dirs by psr loader for apps
            if (array_key_exists('Apps\\', $map)) {
                foreach ($map['Apps\\'] as $appPath) {
                    $this->appRoots[] = $appPath;
                }
            }

            // get Widgets map
            if (array_key_exists('Widgets\\', $map)) {
                // get all available root dirs by psr loader for widgets
                foreach ($map['Widgets\\'] as $widgetPath) {
                    $this->widgetRoots[] = $widgetPath;
                }
            }
        }

        // set default root path if not found anything else
        if (count($this->appRoots) < 1) {
            $this->appRoots = [root];
        }

        if (count($this->widgetRoots) < 1) {
            $this->widgetRoots = [root];
        }
    }
1280337
protected function parse(): void
    {
        switch ($this->notation) {

            case self::NOTATION_DOT_DECIMAL:
                $this->fromDotDecimal($this->value);
                break;

            case self::NOTATION_BINARY:
                $this->fromBinary($this->value);
                break;

            case self::NOTATION_CIDR_SHORT:
                $this->fromCidrShort($this->value);
                break;

            case self::NOTATION_CIDR_LONG:
                $this->fromCidrLong($this->value);
                break;

            case self::NOTATION_CIDR_BINARY:
                $this->fromCidrBinary($this->value);
                break;

            default:
                $this->notation = self::NOTATION_INVALID;
        }
    }
746356
public function parse()
    {
        $this->setDBdat();

        // validate
        if (is_null($this->dbdat) === true) {
            $this->logger->debug('db: data file not found, download the data manually from http://data.udger.com/');
            return array('flag' => 3,
                'errortext' => 'data file not found');
        }

        //ret values
        $ret = array('user_agent' =>
            array('ua_string' => '',
                'ua_class' => '',
                'ua_class_code' => '',
                'ua' => '',
                'ua_version' => '',
                'ua_version_major' => '',
                'ua_uptodate_current_version' => '',
                'ua_family' => '',
                'ua_family_code' => '',
                'ua_family_homepage' => '',
                'ua_family_vendor' => '',
                'ua_family_vendor_code' => '',
                'ua_family_vendor_homepage' => '',
                'ua_family_icon' => '',
                'ua_family_icon_big' => '',
                'ua_family_info_url' => '',
                'ua_engine' => '',
                'os' => '',
                'os_code' => '',
                'os_homepage' => '',
                'os_icon' => '',
                'os_icon_big' => '',
                'os_info_url' => '',
                'os_family' => '',
                'os_family_code' => '',
                'os_family_vendor' => '',
                'os_family_vendor_code' => '',
                'os_family_vendor_homepage' => '',
                'device_class' => '',
                'device_class_code' => '',
                'device_class_icon' => '',
                'device_class_icon_big' => '',
                'device_class_info_url' => '',
                'device_marketname'             => '',
                'device_brand'                  => '',
                'device_brand_code'             => '',
                'device_brand_homepage'         => '',
                'device_brand_icon'             => '',
                'device_brand_icon_big'         => '',
                'device_brand_info_url'         => '',
                'crawler_last_seen' => '',
                'crawler_category' => '',
                'crawler_category_code' => '',
                'crawler_respect_robotstxt' => ''
            ),
            'ip_address' =>
            array('ip' => '',
                'ip_ver' => '',
                'ip_classification' => '',
                'ip_classification_code' => '',
                'ip_hostname' => '',
                'ip_last_seen' => '',
                'ip_country' => '',
                'ip_country_code' => '',
                'ip_city' => '',
                'crawler_name' => '',
                'crawler_ver' => '',
                'crawler_ver_major' => '',
                'crawler_family' => '',
                'crawler_family_code' => '',
                'crawler_family_homepage' => '',
                'crawler_family_vendor' => '',
                'crawler_family_vendor_code' => '',
                'crawler_family_vendor_homepage' => '',
                'crawler_family_icon' => '',
                'crawler_family_info_url' => '',
                'crawler_last_seen' => '',
                'crawler_category' => '',
                'crawler_category_code' => '',
                'crawler_respect_robotstxt' => '',
                'datacenter_name' => '',
                'datacenter_name_code' => '',
                'datacenter_homepage' => ''
            )
        );

        if (!empty($this->ua)) {
            $this->logger->debug("parse useragent string: START (useragent: " . $this->ua . ")");
            
            $usedCache = false;
            if($this->cacheEnable) {
                $retCache = $this->getCache( md5($this->ua) );
                if($retCache) {
                    $ret['user_agent'] = unserialize($retCache);
                    $usedCache = true;
                }
            }
            if(!$usedCache) {             
                $client_id = 0;
                $client_class_id = -1;
                $os_id = 0;
                $deviceclass_id = 0;
                $ret['user_agent']['ua_string'] = $this->ua;
                $ret['user_agent']['ua_class'] = 'Unrecognized';
                $ret['user_agent']['ua_class_code'] = 'unrecognized';

                // crawler            
                $q = $this->dbdat->query("SELECT udger_crawler_list.id as botid,name,ver,ver_major,last_seen,respect_robotstxt,family,family_code,family_homepage,family_icon,vendor,vendor_code,vendor_homepage,crawler_classification,crawler_classification_code
                                              FROM udger_crawler_list
                                              LEFT JOIN udger_crawler_class ON udger_crawler_class.id=udger_crawler_list.class_id
                                              WHERE ua_string='" . $this->dbdat->escapeString($this->ua) . "'");

                if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                    $this->logger->debug("parse useragent string: crawler found");

                    $client_class_id = 99;
                    $ret['user_agent']['ua_class'] = 'Crawler';
                    $ret['user_agent']['ua_class_code'] = 'crawler';
                    $ret['user_agent']['ua'] = $r['name'];
                    $ret['user_agent']['ua_version'] = $r['ver'];
                    $ret['user_agent']['ua_version_major'] = $r['ver_major'];
                    $ret['user_agent']['ua_family'] = $r['family'];
                    $ret['user_agent']['ua_family_code'] = $r['family_code'];
                    $ret['user_agent']['ua_family_homepage'] = $r['family_homepage'];
                    $ret['user_agent']['ua_family_vendor'] = $r['vendor'];
                    $ret['user_agent']['ua_family_vendor_code'] = $r['vendor_code'];
                    $ret['user_agent']['ua_family_vendor_homepage'] = $r['vendor_homepage'];
                    $ret['user_agent']['ua_family_icon'] = $r['family_icon'];
                    $ret['user_agent']['ua_family_info_url'] = "https://udger.com/resources/ua-list/bot-detail?bot=" . $r['family'] . "#id" . $r['botid'];
                    $ret['user_agent']['crawler_last_seen'] = $r['last_seen'];
                    $ret['user_agent']['crawler_category'] = $r['crawler_classification'];
                    $ret['user_agent']['crawler_category_code'] = $r['crawler_classification_code'];
                    $ret['user_agent']['crawler_respect_robotstxt'] = $r['respect_robotstxt'];
                } else {
                    // client
                    $q = $this->dbdat->query("SELECT class_id,client_id,regstring,name,name_code,homepage,icon,icon_big,engine,vendor,vendor_code,vendor_homepage,uptodate_current_version,client_classification,client_classification_code
                                                  FROM udger_client_regex
                                                  JOIN udger_client_list ON udger_client_list.id=udger_client_regex.client_id
                                                  JOIN udger_client_class ON udger_client_class.id=udger_client_list.class_id
                                                  ORDER BY sequence ASC");
                    while ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                        if (@preg_match($r["regstring"], $this->ua, $result)) {
                            $this->logger->debug("parse useragent string: client found");
                            $client_id = $r['client_id'];
                            $client_class_id = $r['class_id'];
                            $ret['user_agent']['ua_class'] = $r['client_classification'];
                            $ret['user_agent']['ua_class_code'] = $r['client_classification_code'];
                            if (isset($result[1])) {
                                $ret['user_agent']['ua'] = $r['name'] . " " . $result[1];
                                $ret['user_agent']['ua_version'] = $result[1];
                                $ver_major = explode(".", $result[1]);
                                $ret['user_agent']['ua_version_major'] = $ver_major[0];
                            } else {
                                $ret['user_agent']['ua'] = $r['name'];
                                $ret['user_agent']['ua_version'] = '';
                                $ret['user_agent']['ua_version_major'] = '';
                            }
                            $ret['user_agent']['ua_uptodate_current_version'] = $r['uptodate_current_version'];
                            $ret['user_agent']['ua_family'] = $r['name'];
                            $ret['user_agent']['ua_family_code'] = $r['name_code'];
                            $ret['user_agent']['ua_family_homepage'] = $r['homepage'];
                            $ret['user_agent']['ua_family_vendor'] = $r['vendor'];
                            $ret['user_agent']['ua_family_vendor_code'] = $r['vendor_code'];
                            $ret['user_agent']['ua_family_vendor_homepage'] = $r['vendor_homepage'];
                            $ret['user_agent']['ua_family_icon'] = $r['icon'];
                            $ret['user_agent']['ua_family_icon_big'] = $r['icon_big'];
                            $ret['user_agent']['ua_family_info_url'] = "https://udger.com/resources/ua-list/browser-detail?browser=" . $r['name'];
                            $ret['user_agent']['ua_engine'] = $r['engine'];
                            break;
                        }
                    }
                    // os
                    $q = $this->dbdat->query("SELECT os_id,regstring,family,family_code,name,name_code,homepage,icon,icon_big,vendor,vendor_code,vendor_homepage
                                                  FROM udger_os_regex
                                                  JOIN udger_os_list ON udger_os_list.id=udger_os_regex.os_id
                                                  ORDER BY sequence ASC");
                    while ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                        if (@preg_match($r["regstring"], $this->ua, $result)) {
                            $this->logger->debug("parse useragent string: os found");
                            $os_id = $r['os_id'];
                            $ret['user_agent']['os'] = $r['name'];
                            $ret['user_agent']['os_code'] = $r['name_code'];
                            $ret['user_agent']['os_homepage'] = $r['homepage'];
                            $ret['user_agent']['os_icon'] = $r['icon'];
                            $ret['user_agent']['os_icon_big'] = $r['icon_big'];
                            $ret['user_agent']['os_info_url'] = "https://udger.com/resources/ua-list/os-detail?os=" . $r['name'];
                            $ret['user_agent']['os_family'] = $r['family'];
                            $ret['user_agent']['os_family_code'] = $r['family_code'];
                            $ret['user_agent']['os_family_vendor'] = $r['vendor'];
                            $ret['user_agent']['os_family_vendor_code'] = $r['vendor_code'];
                            $ret['user_agent']['os_family_vendor_homepage'] = $r['vendor_homepage'];
                            break;
                        }
                    }
                    // client_os_relation
                    if ($os_id == 0 AND $client_id != 0) {
                        $q = $this->dbdat->query("SELECT os_id,family,family_code,name,name_code,homepage,icon,icon_big,vendor,vendor_code,vendor_homepage
                                                      FROM udger_client_os_relation
                                                      JOIN udger_os_list ON udger_os_list.id=udger_client_os_relation.os_id
                                                      WHERE client_id=" . $client_id . " ");
                        if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                            $this->logger->debug("parse useragent string: client os relation found");
                            $os_id = $r['os_id'];
                            $ret['user_agent']['os'] = $r['name'];
                            $ret['user_agent']['os_code'] = $r['name_code'];
                            $ret['user_agent']['os_homepage'] = $r['homepage'];
                            $ret['user_agent']['os_icon'] = $r['icon'];
                            $ret['user_agent']['os_icon_big'] = $r['icon_big'];
                            $ret['user_agent']['os_info_url'] = "https://udger.com/resources/ua-list/os-detail?os=" . $r['name'];
                            $ret['user_agent']['os_family'] = $r['family'];
                            $ret['user_agent']['os_family_code'] = $r['family_code'];
                            $ret['user_agent']['os_family_vendor'] = $r['vendor'];
                            $ret['user_agent']['os_family_vendor_code'] = $r['vendor_code'];
                            $ret['user_agent']['os_family_vendor_homepage'] = $r['vendor_homepage'];
                        }
                    }
                    //device
                    $q = $this->dbdat->query("SELECT deviceclass_id,regstring,name,name_code,icon,icon_big
                                                  FROM udger_deviceclass_regex
                                                  JOIN udger_deviceclass_list ON udger_deviceclass_list.id=udger_deviceclass_regex.deviceclass_id
                                                  ORDER BY sequence ASC");

                    while ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                        if (@preg_match($r["regstring"], $this->ua, $result)) {
                            $this->logger->debug("parse useragent string: device found by regex");
                            $deviceclass_id = $r['deviceclass_id'];
                            $ret['user_agent']['device_class'] = $r['name'];
                            $ret['user_agent']['device_class_code'] = $r['name_code'];
                            $ret['user_agent']['device_class_icon'] = $r['icon'];
                            $ret['user_agent']['device_class_icon_big'] = $r['icon_big'];
                            $ret['user_agent']['device_class_info_url'] = "https://udger.com/resources/ua-list/device-detail?device=" . $r['name'];
                            break;
                        }
                    }
                    if ($deviceclass_id == 0 AND $client_class_id != -1) {
                        $q = $this->dbdat->query("SELECT deviceclass_id,name,name_code,icon,icon_big 
                                                  FROM udger_deviceclass_list
                                                  JOIN udger_client_class ON udger_client_class.deviceclass_id=udger_deviceclass_list.id
                                                  WHERE udger_client_class.id=" . $client_class_id . " ");
                        if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                            $this->logger->debug("parse useragent string: device found by deviceclass");
                            $deviceclass_id = $r['deviceclass_id'];
                            $ret['user_agent']['device_class'] = $r['name'];
                            $ret['user_agent']['device_class_code'] = $r['name_code'];
                            $ret['user_agent']['device_class_icon'] = $r['icon'];
                            $ret['user_agent']['device_class_icon_big'] = $r['icon_big'];
                            $ret['user_agent']['device_class_info_url'] = "https://udger.com/resources/ua-list/device-detail?device=" . $r['name'];
                        }
                    }

                    // device marketname
                    if($ret['user_agent']['os_family_code']) { 
                        $q = $this->dbdat->query("SELECT id,regstring FROM udger_devicename_regex WHERE 
                                                  ((os_family_code='".$ret['user_agent']['os_family_code']."' AND os_code='-all-') 
                                                  OR 
                                                  (os_family_code='".$ret['user_agent']['os_family_code']."' AND os_code='".$ret['user_agent']['os_code']."'))
                                                  order by sequence");
                        while ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                            @preg_match($r["regstring"],$this->ua,$result);                        

                            if(array_key_exists(1, $result)) {
                                $qC=$this->dbdat->query("SELECT marketname,brand_code,brand,brand_url,icon,icon_big
                                                         FROM udger_devicename_list
                                                         JOIN udger_devicename_brand ON udger_devicename_brand.id=udger_devicename_list.brand_id 
                                                         WHERE regex_id=".$r["id"]." and code = '".\SQLite3::escapeString(trim($result[1]))."' COLLATE NOCASE  ");

                                if($rC = $qC->fetchArray(SQLITE3_ASSOC)) {
                                    $this->logger->debug("parse useragent string: device marketname found");
                                    $ret['user_agent']['device_marketname']       = $rC['marketname'];
                                    $ret['user_agent']['device_brand']            = $rC['brand'];
                                    $ret['user_agent']['device_brand_code']       = $rC['brand_code'];
                                    $ret['user_agent']['device_brand_homepage']   = $rC['brand_url'];
                                    $ret['user_agent']['device_brand_icon']       = $rC['icon'];
                                    $ret['user_agent']['device_brand_icon_big']   = $rC['icon_big'];
                                    $ret['user_agent']['device_brand_info_url']   = "https://udger.com/resources/ua-list/devices-brand-detail?brand=".$rC['brand_code'];                             

                                    break;
                                }                
                            }
                        }
                    }
                    if($this->cacheEnable) {
                        $this->setCache( md5($this->ua) , serialize($ret['user_agent']) );
                    }
                }
            }

            $this->logger->debug("parse useragent string: END, unset useragent string");
            $this->ua = '';
        }

        if (!empty($this->ip)) {
            $this->logger->debug("parse IP address: START (IP: " . $this->ip . ")");
            $ret['ip_address']['ip'] = $this->ip;
            $ipver = $this->ipHelper->getIpVersion($this->ip);
            
            if ($ipver !== false) {
                if ($ipver === IPInterface::IPv6) {
                    $this->ip = inet_ntop(inet_pton($this->ip));
                    $this->logger->debug("compress IP address is:" . $this->ip);
                }

                $ret['ip_address']['ip_ver'] = $ipver;
                $q = $this->dbdat->query("SELECT udger_crawler_list.id as botid,ip_last_seen,ip_hostname,ip_country,ip_city,ip_country_code,ip_classification,ip_classification_code,
                                          name,ver,ver_major,last_seen,respect_robotstxt,family,family_code,family_homepage,family_icon,vendor,vendor_code,vendor_homepage,crawler_classification,crawler_classification_code
                                          FROM udger_ip_list
                                          JOIN udger_ip_class ON udger_ip_class.id=udger_ip_list.class_id
                                          LEFT JOIN udger_crawler_list ON udger_crawler_list.id=udger_ip_list.crawler_id
                                          LEFT JOIN udger_crawler_class ON udger_crawler_class.id=udger_crawler_list.class_id
                                          WHERE ip='" . $this->ip . "' ORDER BY sequence");
                
                if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                    $ret['ip_address']['ip_classification'] = $r['ip_classification'];
                    $ret['ip_address']['ip_classification_code'] = $r['ip_classification_code'];
                    $ret['ip_address']['ip_last_seen'] = $r['ip_last_seen'];
                    $ret['ip_address']['ip_hostname'] = $r['ip_hostname'];
                    $ret['ip_address']['ip_country'] = $r['ip_country'];
                    $ret['ip_address']['ip_country_code'] = $r['ip_country_code'];
                    $ret['ip_address']['ip_city'] = $r['ip_city'];

                    $ret['ip_address']['crawler_name'] = $r['name'];
                    $ret['ip_address']['crawler_ver'] = $r['ver'];
                    $ret['ip_address']['crawler_ver_major'] = $r['ver_major'];
                    $ret['ip_address']['crawler_family'] = $r['family'];
                    $ret['ip_address']['crawler_family_code'] = $r['family_code'];
                    $ret['ip_address']['crawler_family_homepage'] = $r['family_homepage'];
                    $ret['ip_address']['crawler_family_vendor'] = $r['vendor'];
                    $ret['ip_address']['crawler_family_vendor_code'] = $r['vendor_code'];
                    $ret['ip_address']['crawler_family_vendor_homepage'] = $r['vendor_homepage'];
                    $ret['ip_address']['crawler_family_icon'] = $r['family_icon'];
                    if ($r['ip_classification_code'] == 'crawler') {
                        $ret['ip_address']['crawler_family_info_url'] = "https://udger.com/resources/ua-list/bot-detail?bot=" . $r['family'] . "#id" . $r['botid'];
                    }
                    $ret['ip_address']['crawler_last_seen'] = $r['last_seen'];
                    $ret['ip_address']['crawler_category'] = $r['crawler_classification'];
                    $ret['ip_address']['crawler_category_code'] = $r['crawler_classification_code'];
                    $ret['ip_address']['crawler_respect_robotstxt'] = $r['respect_robotstxt'];
                } else {
                    $ret['ip_address']['ip_classification'] = 'Unrecognized';
                    $ret['ip_address']['ip_classification_code'] = 'unrecognized';
                }
                
                if ($this->ipHelper->getIpVersion($ret['ip_address']['ip']) === IPInterface::IPv4) {
                    
                    $ipLong = $this->ipHelper->getIpLong($ret['ip_address']['ip']);
                    
                    $q = $this->dbdat->query("select name,name_code,homepage 
                                       FROM udger_datacenter_range
                                       JOIN udger_datacenter_list ON udger_datacenter_range.datacenter_id=udger_datacenter_list.id
                                       where iplong_from <= " . $ipLong . " AND iplong_to >= " . $ipLong . " ");
                    
                    if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                        $ret['ip_address']['datacenter_name'] = $r['name'];
                        $ret['ip_address']['datacenter_name_code'] = $r['name_code'];
                        $ret['ip_address']['datacenter_homepage'] = $r['homepage'];
                    }
                }                
                else if ($this->ipHelper->getIpVersion($ret['ip_address']['ip']) === IPInterface::IPv6) {
                    $ipInt = $this->ipHelper->getIp6array($ret['ip_address']['ip']);
                    $q = $this->dbdat->query("select name,name_code,homepage 
                                          FROM udger_datacenter_range6
                                          JOIN udger_datacenter_list ON udger_datacenter_range6.datacenter_id=udger_datacenter_list.id
                                          where 
                                          iplong_from0 <= ".$ipInt[0]." AND iplong_to0 >= ".$ipInt[0]." AND
                                          iplong_from1 <= ".$ipInt[1]." AND iplong_to1 >= ".$ipInt[1]." AND
                                          iplong_from2 <= ".$ipInt[2]." AND iplong_to2 >= ".$ipInt[2]." AND
                                          iplong_from3 <= ".$ipInt[3]." AND iplong_to3 >= ".$ipInt[3]." AND
                                          iplong_from4 <= ".$ipInt[4]." AND iplong_to4 >= ".$ipInt[4]." AND
                                          iplong_from5 <= ".$ipInt[5]." AND iplong_to5 >= ".$ipInt[5]." AND
                                          iplong_from6 <= ".$ipInt[6]." AND iplong_to6 >= ".$ipInt[6]." AND
                                          iplong_from7 <= ".$ipInt[7]." AND iplong_to7 >= ".$ipInt[7]." 
                                          ");
                                                  
                    if ($r = $q->fetchArray(SQLITE3_ASSOC)) {
                        $ret['ip_address']['datacenter_name'] = $r['name'];
                        $ret['ip_address']['datacenter_name_code'] = $r['name_code'];
                        $ret['ip_address']['datacenter_homepage'] = $r['homepage'];
                    }
                }
            }

            $this->logger->debug("parse IP address: END, unset IP address");
            $this->ip = '';
        }
        return $ret;
    }