Parses a SQL file containing simple statements.
@return void
@throws tao_install_utils_SQLParsingException
19653
public function parse(){
		$this->setStatements(array());
		
		//common file checks
		$file = $this->getFile();
		if (!file_exists($file)){
			throw new tao_install_utils_SQLParsingException("SQL file '${file}' does not exist.");
		}
		else if (!is_readable($file)){
			throw new tao_install_utils_SQLParsingException("SQL file '${file}' is not readable.");
		}
		else if(!preg_match("/\.sql$/", basename($file))){
			throw new tao_install_utils_SQLParsingException("File '${file}' is not a valid SQL file. Extension '.sql' not found.");
		}
		
		if ($handler = fopen($file, "r")){
			
			//parse file and get only usefull lines
			$ch = "";
			while (!feof ($handler)){
				$line = utf8_decode(fgets($handler));
		
				if (isset($line[0]) && ($line[0] != '#') && ($line[0] != '-')){
					$ch = $ch.$line;
				}
			}
			
			//explode and execute
			$requests = explode(";", $ch);
			
			try{
				foreach($requests as $index => $request){
					$requestTrim = trim($request);
					if(!empty($requestTrim)){
						$this->addStatement($request);
					}
				}
			}
			catch(Exception $e){
				throw new tao_install_utils_SQLParsingException("Error executing query #$index : $request . ".$e->getMessage());
			}
			fclose($handler);
		}
	}
930394
public void parse(final InsertStatement insertStatement) {
        Collection<Keyword> valueKeywords = new LinkedList<>();
        valueKeywords.add(DefaultKeyword.VALUES);
        valueKeywords.addAll(Arrays.asList(getSynonymousKeywordsForValues()));
        if (lexerEngine.skipIfEqual(valueKeywords.toArray(new Keyword[valueKeywords.size()]))) {
            parseValues(insertStatement);
        }
    }
636843
public function parse()
	{
		$i=0;
		$lines	= $this->read();
		foreach( $lines as $line )
			$this->data[]	= array_combine( $this->_pattern, $line );
	}
786786
public function setup_is_unicodedb() {
        $sql = "SELECT VALUE
                  FROM NLS_DATABASE_PARAMETERS
                 WHERE PARAMETER = 'NLS_CHARACTERSET'";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $stmt = $this->parse_query($sql);
        $result = oci_execute($stmt, $this->commit_status);
        $this->query_end($result, $stmt);
        $records = null;
        oci_fetch_all($stmt, $records, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN);
        oci_free_statement($stmt);

        return (isset($records['VALUE'][0]) and $records['VALUE'][0] === 'AL32UTF8');
    }
1141634
public function parse()
    {
        $this->lexer->moveNext();

        while (true) {
            if (!$this->lexer->lookahead) {
                break;
            }

            $this->lexer->moveNext();
            $thisLine = null;

            switch ($this->lexer->token['type']) {
                case Lexer::T_OPEN_PARENTHESIS:
                case Lexer::T_OPEN_BRACKET:
                case Lexer::T_OPEN_CURLY_BRACE:
                    $thisLine = '[';
                    $this->currentLevel++;
                    break;
                case Lexer::T_CLOSE_PARENTHESIS:
                case Lexer::T_CLOSE_BRACKET:
                case Lexer::T_CLOSE_CURLY_BRACE:
                    $thisLine = ']';
                    $this->currentLevel--;
                    break;
                case Lexer::T_STRING:
                    $thisLine = "'".str_replace("'", "\'", $this->lexer->token['value'])."'";
                    break;
                case Lexer::T_DOUBLEPOINT:
                    $thisLine = '=>';
                    break;
                case Lexer::T_COMMENT_PARAMSTART:
                    $paramName = $this->lexer->lookahead['value'];
                    $thisLine = '$this->getParam("'.$paramName.'")';
                    // scroll to end of param
                    while ($this->lexer->token['type'] != Lexer::T_COMMENT_PARAMEND) {
                        $this->lexer->moveNext();
                    }
                    break;
                case Lexer::T_COMMENT_IFPARAMSTART:
                case Lexer::T_COMMENT_IFNOTPARAMSTART:
                    $conditionalId = str_pad((string) $this->conditionalCounter, 5, '0', STR_PAD_LEFT);
                    $this->conditionalCounter++;

                    $isNegated = '';
                    if ($this->lexer->token['type'] == Lexer::T_COMMENT_IFNOTPARAMSTART) {
                        $isNegated = 'true';
                    }

                    $this->addContent('$this->getConditional'.$conditionalId.'('.$isNegated.'),');
                    $this->openConditional($conditionalId, $this->lexer->lookahead['value']);
                    break;
                case Lexer::T_COMMENT_IFPARAMEND:
                case Lexer::T_COMMENT_IFNOTPARAMEND:
                    $this->closeConditional();
                    break;
                case Lexer::T_DATE_EMPTY:
                    $thisLine = 'new '.$this->mongoDateClass.'()';
                    break;
                case Lexer::T_DATE_WITH_PARAM:
                    $paramName = $this->lexer->lookahead['value'];
                    $thisLine = '$this->getParam("'.$paramName.'")';
                    break;
                case Lexer::T_BOOLEAN_TRUE:
                    $thisLine = 'true';
                    break;
                case Lexer::T_BOOLEAN_FALSE:
                    $thisLine = 'false';
                    break;
                case Lexer::T_NULL:
                    $thisLine = 'null';
                    break;
                case Lexer::T_COMMA:
                case Lexer::T_NUMBER:
                case Lexer::T_DASH:
                    $thisLine = $this->lexer->token['value'];
                    break;
                default:
                    // nothing
            }

            if (!is_null($thisLine)) {
                $this->addContent($thisLine);
            }
        }

        return implode(PHP_EOL, $this->lines);
    }
449270
public function parse()
    {
        $raw = $this->getRaw();
        $count = count($raw);
        for ($i = 7; $i < $count; $i++) {
            $line = $raw[$i];

            $process = new Process(
                $line[11],
                $line[0],
                floatval($line[8]),
                floatval($line[9])
            );

            $this->processes[] = $process;
        }
    }
678124
public function load($sql)
    {
        $query = '';
        $delimiter = ';';
        $delimiterLength = 1;

        $dollarsOpen = false;
        foreach ($sql as $sqlLine) {
            if (preg_match('/DELIMITER ([\;\$\|\\\\]+)/i', $sqlLine, $match)) {
                $delimiter = $match[1];
                $delimiterLength = strlen($delimiter);
                continue;
            }

            $parsed = trim($query) == '' && $this->sqlLine($sqlLine);
            if ($parsed) {
                continue;
            }

            // Ignore $$ inside SQL standard string syntax such as in INSERT statements.
            if (!preg_match('/\'.*\$\$.*\'/', $sqlLine)) {
                $pos = strpos($sqlLine, '$$');
                if (($pos !== false) && ($pos >= 0)) {
                    $dollarsOpen = !$dollarsOpen;
                }
            }

            if (preg_match('/SET search_path = .*/i', $sqlLine, $match)) {
                $this->searchPath = $match[0];
            }

            $query .= "\n" . rtrim($sqlLine);

            if (!$dollarsOpen && substr($query, -1 * $delimiterLength, $delimiterLength) == $delimiter) {
                $this->sqlQuery(substr($query, 0, -1 * $delimiterLength));
                $query = '';
            }
        }

        if ($query !== '') {
            $this->sqlQuery($query);
        }
    }
1231752
public function parse()
    {
        if (isset($this->view)) return;

        if ($this->viewParser instanceof StyleAwareInterface
            and $this->styleParser) {

            $style = $this->styleParser->parse($this->stylePath);

            if ($style) $this->viewParser->setStyle($style);
        }

        $view = $this->viewParser->parse($this->viewPath);

        if ($view instanceof ControllerAwareInterface) {
            $view->setController($this->controller);
        }

        $this->view = $view;
    }
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;
    }
702327
public function run()
    {
        // from install folder
        if (! file_exists($this->parameters['previous'])) {
            $this->err('Previous tao directory "' . $this->parameters['previous'] . '" found', true);
        }
        
        $outDir = $this->parameters['output'];
        if (! file_exists($outDir)) {
            if (! mkdir($outDir)) {
                $this->err('Could not create directory "' . $outDir, true);
            }
        }
        
        $oldExts = $this->getAllExtensionManifests($this->parameters['previous']);
        $newExts = $this->getAllExtensionManifests(ROOT_PATH);
        
        foreach ($oldExts as $extId => $manifest) {
            $extDiff = new taoDevTools_models_ExtDiff($manifest, isset($newExts[$extId]) ? $newExts[$extId] : null);
            file_put_contents($outDir . DIRECTORY_SEPARATOR . 'diff' . ucfirst($extId) . '.php', $extDiff->exportDiffToPhp());
            file_put_contents($outDir . DIRECTORY_SEPARATOR . 'diff' . ucfirst($extId) . '.sql', $extDiff->exportDiffToSql());
            if (! isset($newExts[$extId])) {
                $this->out('Extension ' . $extId . ' no longer exists.');
            }
        }
    }
719841
public static function parseCommand()
    {
        global $argv;
        foreach($argv as $file)
        {
            $ext = pathinfo($file, PATHINFO_EXTENSION );
            if($ext !== 'php')
            {
                continue;
            }
            if(is_file($file))
            {
                static::$_startFiles[$file] = $file;
                include_once $file;
            }
        }
    }
732407
private function _loadSqlFile()
    {
        $fileObj = fopen($this->_sqlFile, 'r');
        $sql = fread($fileObj, filesize($this->_sqlFile));
        fclose($fileObj);
        return $sql;
    }
466649
protected function buildQueryString() {

		$w = [];
		$s = [];

		$qc = $this->quoteChar;

		// start SQL statement

		$this->sql = 'SELECT ';

		// add columns

		if(!$this->columns || !count($this->columns)) {
			$this->sql .= '*';
		}
		else {
			
			$this->sql .= $qc . str_replace('.', $qc . '.' . $qc, implode($qc . ',' . $qc, $this->columns)) . $qc;
				
		}

		// add table

		$this->sql .= ' FROM ' . $qc . preg_replace('/\s+/', $qc . ' ' . $qc, $this->table) . $qc;

		// add alias

		if($this->alias) {
			$this->sql .= ' ' . $qc . $this->alias . $qc;
		}

		// add INNER JOINs

		foreach($this->innerJoins as $join) {
			$this->sql .= sprintf(' INNER JOIN %1$s%2$s%1$s ON %3$s', $qc, preg_replace('/\s+/', $qc . ' ' . $qc, trim($join->table)), $join->on);
		}

		// build WHERE clause

		foreach($this->whereClauses as $where) {

			// complete condition when no operator set

			if(!$where->operator) {
				$w[] = $where->conditionOrColumn;
			}

			// otherwise parse operator

			else {
				if($where->operator === 'IN') {
					$w[] = sprintf(
						'%1$s%2$s%1$s IN (%3$s)',
						$qc,
						str_replace('.', $qc . '.' . $qc, $where->conditionOrColumn),
						implode(', ', array_fill(0, count($where->value), '?'))
					);
				}
				else {
					$w[] = sprintf(
						'%1$s%2$s%1$s %3$s ?',
						$qc,
						str_replace('.', $qc . '.' . $qc, $where->conditionOrColumn),
						$where->operator
					);
				}
			}
		}

		// build SORT clause

		foreach($this->columnSorts as $sort) {
			$s[] = $sort->column . ($sort->asc ? '' : ' DESC');
		}

		if(count($w)) {
			$this->sql .= ' WHERE (' . implode(') AND (', $w) .')';
		}
		if(count($s)) {
			$this->sql .= ' ORDER BY ' . implode(', ', $s);
		}

	}
570116
public function parse_sql($sql, $as_is = false){
		if ($as_is){
			$this->fieldset = $sql;
			return;
		}

		$sql= preg_replace("/[ \n\t]+limit[\n\t ,0-9]*$/i","",$sql);
		
		$data = preg_split("/[ \n\t]+\\_from\\_/i",$sql,2);
		if (count($data)!=2)
			$data = preg_split("/[ \n\t]+from/i",$sql,2);
		$this->fieldset = preg_replace("/^[\s]*select/i","",$data[0],1);

		//Ignore next type of calls
		//direct call to stored procedure without FROM
		if ((count($data) == 1) ||
			//UNION select
			preg_match("#[ \n\r\t]union[ \n\t\r]#i", $sql)){
				$this->fieldset = $sql;
				return;
		}

	  	$table_data = preg_split("/[ \n\t]+where/i",$data[1],2);
	  	/*
		  		if sql code contains group_by we will place all sql query in the FROM 
		  		it will not allow to use any filtering against the query
		  		still it is better than just generate incorrect sql commands for any group by query
	  	*/
	  	if (sizeof($table_data)>1 && !preg_match("#.*group by.*#i",$table_data[1])){ //where construction exists
	  		$this->set_source($table_data[0]);
  			$where_data = preg_split("/[ \n\t]+order[ ]+by/i",$table_data[1],2);
  			$this->filters[]=$where_data[0];
  			if (sizeof($where_data)==1) return; //end of line detected
  			$data=$where_data[1];
  		} else { 
  			$table_data = preg_split("/[ \n\t]+order[ ]+by/i",$data[1],2);	
  			$this->set_source($table_data[0]);
  			if (sizeof($table_data)==1) return; //end of line detected
  			$data=$table_data[1];
  		}
	  	
      	if (trim($data)){ //order by construction exists
			$s_data = preg_split("/\\,/",trim($data));
			for ($i=0; $i < count($s_data); $i++) { 
				$data=preg_split("/[ ]+/",trim($s_data[$i]),2);
				if (sizeof($data)>1)
					$this->set_sort($data[0],$data[1]);
				else
					$this->set_sort($data[0]);
			}
			
		}
	}
115525
private function parsing() : void
    {
        $lines = explode("\n", $this->raw);

        foreach ($lines as $line) {
            // check "at" mark
            if (false === strpos($line, '@')) {
                continue;
            }

            // check inline annotation
            if ($anp = strpos($line, '//')) {
                $line = substr($line, 0, $anp);
            }

            // trim blanks
            $line = trim(ltrim($line, ' *'));

            // analyze expr
            if (false === $fws = strpos($line, ' ')) {
                // @some-key
                $key = substr($line, 1);
                $val = true;
            } else {
                // @some-key some-val
                $key = substr($line, 1, $fws - 1);
                $val = trim(substr($line, $fws));
            }

            $this->lines[] = [$key, $val];

            $this->declares[$key][] = $val;
        }
    }
1175646
public function init()
    {

        // initialize the parend class
        parent::init();

        // initialize the prepared statements
        $this->categoryVarcharsStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CATEGORY_VARCHARS));
        $this->categoryVarcharsByPkAndStoreIdStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CATEGORY_VARCHARS_BY_PK_AND_STORE_ID));
    }
1280749
public function read()
    {

        $file = $this->getFilePath();
        if (!file_exists($file)) {
            throw new tao_helpers_translation_TranslationException("The translation file '${file}' does not exist.");
        }

        // Create the translation file.
        $tf = new tao_helpers_translation_POFile();

        $fc = implode('',file($file));

        $matched = preg_match_all('/((?:#[\.:,\|]{0,1}\s+(?:.*?)\\n)*)'.
            '(msgctxt\s+(?:"(?:[^"]|\\\\")*?"\s*)+)?'.
            '(msgid\s+(?:"(?:[^"]|\\\\")*?"\s*)+)\s+' .
            '(msgstr\s+(?:"(?:[^"]|\\\\")*?(?<!\\\)"\s*)+)/',
            $fc, $matches);

        preg_match('/sourceLanguage: (.*?)\\n/s', $fc, $sourceLanguage);
        preg_match('/targetLanguage: (.*?)\\n/s', $fc, $targetLanguage);

        if (count($sourceLanguage)) {
            $tf->setSourceLanguage(substr($sourceLanguage[1],0,5));
        }
        if (count($targetLanguage)) {
            $tf->setTargetLanguage(substr($targetLanguage[1],0,5));
        }

        if ($matched) {

            for ($i = 0; $i < $matched; $i++) {

                $annotations = $matches[1][$i];
                $msgctxt = preg_replace('/\s*msgctxt\s*"(.*)"\s*/s','\\1',$matches[2][$i]);
                $msgid = preg_replace('/\s*msgid\s*"(.*)"\s*/s','\\1',$matches[3][$i]);
                $msgstr = preg_replace('/\s*msgstr\s*"(.*)"\s*/s','\\1',$matches[4][$i]);

                // Do not include meta data as a translation unit..
                if ($msgid !== ''){

                    // Sanitze the strings.
                    $msgid = tao_helpers_translation_POUtils::sanitize($msgid);
                    $msgstr = tao_helpers_translation_POUtils::sanitize($msgstr);
                    $msgctxt = tao_helpers_translation_POUtils::sanitize($msgctxt);
                    $tu = new tao_helpers_translation_POTranslationUnit();

                    // Set up source & target.
                    $tu->setSource($msgid);
                    if ($msgstr !== '') {
                        $tu->setTarget($msgstr);
                    }
                    if ($msgctxt){
                        $tu->setContext($msgctxt);
                    }

                    // Deal with annotations
                    $annotations = tao_helpers_translation_POUtils::unserializeAnnotations($annotations);
                    foreach ($annotations as $name => $value){
                        $tu->addAnnotation($name, $value);
                    }

                    $tf->addTranslationUnit($tu);
                }
			}
		}

		$this->setTranslationFile($tf);

    }