Get visitor IP address

@param ConnectionInterface $conn
@throws \Sonar\Exceptions\AppServiceException
@return string
501577
private function getLanguage(ConnectionInterface $conn) {

        if($conn->WebSocket instanceof \StdClass) {
            $language = $conn->WebSocket->request->getHeader('Accept-Language');
            $language = trim(strtoupper(substr($language, 0, 2)));

            return (empty($language) === false) ? $language :'Unknown';
        }
        throw new AppServiceException('Language not defined');
    }
1094463
public function getConnectionAddress():string
    {
        $serviceList  = $this->getServiceList();
        if (App::hasBean('balancerSelector')) {
            $balancerType = $this->poolConfig->getBalancer();
            $balancer     = balancer()->select($balancerType);
            return $balancer->select($serviceList);
        }
        return current($serviceList);
    }
525996
private function authenticateUser(ConnectionInterface $conn)
    {
        $queryParameters = [];
        parse_str($conn->httpRequest->getUri()->getQuery(), $queryParameters);

        if (!isset($queryParameters['access_token'])) {
            return null;
        }

        $accessToken = $queryParameters['access_token'];
        $authenticationManager = $this->sandstoneApplication['security.authentication_manager'];

        $authenticatedToken = $authenticationManager->authenticate(new OAuth2Token($accessToken));
        $user = $authenticatedToken->getUser();
        $isUser = $user instanceof UserInterface;

        if (!$isUser) {
            throw new \Exception('User not found.');
        }

        return $user;
    }
763599
public function getParent(ConnectionInterface $con = null)
    {
        if (null === $this->aNestedSetParent && $this->hasParent()) {
            $this->aNestedSetParent = ChildCategoryQuery::create()
                ->ancestorsOf($this)
                ->orderByLevel(true)
                ->findOne($con);
        }

        return $this->aNestedSetParent;
    }
1183467
public function getProduct(ConnectionInterface $con = null)
    {
        if ($this->aProduct === null && ($this->product_id !== null)) {
            $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aProduct->addDealerProducts($this);
             */
        }

        return $this->aProduct;
    }
213377
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[FeatureTypeTableMap::ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureTypeTableMap::ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(FeatureTypeTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::SLUG)) {
            $modifiedColumns[':p' . $index++]  = 'SLUG';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE)) {
            $modifiedColumns[':p' . $index++]  = 'HAS_FEATURE_AV_VALUE';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE)) {
            $modifiedColumns[':p' . $index++]  = 'IS_MULTILINGUAL_FEATURE_AV_VALUE';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::PATTERN)) {
            $modifiedColumns[':p' . $index++]  = 'PATTERN';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::CSS_CLASS)) {
            $modifiedColumns[':p' . $index++]  = 'CSS_CLASS';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::INPUT_TYPE)) {
            $modifiedColumns[':p' . $index++]  = 'INPUT_TYPE';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::MAX)) {
            $modifiedColumns[':p' . $index++]  = 'MAX';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::MIN)) {
            $modifiedColumns[':p' . $index++]  = 'MIN';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::STEP)) {
            $modifiedColumns[':p' . $index++]  = 'STEP';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::IMAGE_MAX_WIDTH)) {
            $modifiedColumns[':p' . $index++]  = 'IMAGE_MAX_WIDTH';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::IMAGE_MAX_HEIGHT)) {
            $modifiedColumns[':p' . $index++]  = 'IMAGE_MAX_HEIGHT';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::IMAGE_RATIO)) {
            $modifiedColumns[':p' . $index++]  = 'IMAGE_RATIO';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(FeatureTypeTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }

        $sql = sprintf(
            'INSERT INTO feature_type (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'SLUG':
                        $stmt->bindValue($identifier, $this->slug, PDO::PARAM_STR);
                        break;
                    case 'HAS_FEATURE_AV_VALUE':
                        $stmt->bindValue($identifier, $this->has_feature_av_value, PDO::PARAM_INT);
                        break;
                    case 'IS_MULTILINGUAL_FEATURE_AV_VALUE':
                        $stmt->bindValue($identifier, $this->is_multilingual_feature_av_value, PDO::PARAM_INT);
                        break;
                    case 'PATTERN':
                        $stmt->bindValue($identifier, $this->pattern, PDO::PARAM_STR);
                        break;
                    case 'CSS_CLASS':
                        $stmt->bindValue($identifier, $this->css_class, PDO::PARAM_STR);
                        break;
                    case 'INPUT_TYPE':
                        $stmt->bindValue($identifier, $this->input_type, PDO::PARAM_STR);
                        break;
                    case 'MAX':
                        $stmt->bindValue($identifier, $this->max, PDO::PARAM_STR);
                        break;
                    case 'MIN':
                        $stmt->bindValue($identifier, $this->min, PDO::PARAM_STR);
                        break;
                    case 'STEP':
                        $stmt->bindValue($identifier, $this->step, PDO::PARAM_STR);
                        break;
                    case 'IMAGE_MAX_WIDTH':
                        $stmt->bindValue($identifier, $this->image_max_width, PDO::PARAM_STR);
                        break;
                    case 'IMAGE_MAX_HEIGHT':
                        $stmt->bindValue($identifier, $this->image_max_height, PDO::PARAM_STR);
                        break;
                    case 'IMAGE_RATIO':
                        $stmt->bindValue($identifier, $this->image_ratio, PDO::PARAM_STR);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
1265241
public function getPlayer(ConnectionInterface $con = null)
    {
        if ($this->aPlayer === null && ($this->player_id !== null)) {
            $this->aPlayer = PlayerQuery::create()->findPk($this->player_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aPlayer->addRecords($this);
             */
        }

        return $this->aPlayer;
    }
1063795
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(DealerAdminVersionTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::DEALER_ID)) {
            $modifiedColumns[':p' . $index++]  = 'DEALER_ID';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::ADMIN_ID)) {
            $modifiedColumns[':p' . $index++]  = 'ADMIN_ID';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_AT';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION_CREATED_BY)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_BY';
        }
        if ($this->isColumnModified(DealerAdminVersionTableMap::DEALER_ID_VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'DEALER_ID_VERSION';
        }

        $sql = sprintf(
            'INSERT INTO dealer_admin_version (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'DEALER_ID':
                        $stmt->bindValue($identifier, $this->dealer_id, PDO::PARAM_INT);
                        break;
                    case 'ADMIN_ID':
                        $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION':
                        $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
                        break;
                    case 'VERSION_CREATED_AT':
                        $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION_CREATED_BY':
                        $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
                        break;
                    case 'DEALER_ID_VERSION':
                        $stmt->bindValue($identifier, $this->dealer_id_version, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        $this->setNew(false);
    }
542275
public function getPermission(ConnectionInterface $con = null)
    {
        if ($this->aPermission === null && ($this->permission_id !== null)) {
            $this->aPermission = ChildPermissionQuery::create()->findPk($this->permission_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aPermission->addRolePermissions($this);
             */
        }

        return $this->aPermission;
    }
754872
protected function getIPAddress( \Psr\Http\Message\ServerRequestInterface $request )
	{
		$server = $request->getServerParams();
		$flags = FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6;

		if( isset( $server['REMOTE_ADDR'] )
			&& ( $ip = filter_var( $server['REMOTE_ADDR'], FILTER_VALIDATE_IP, $flags ) ) !== false
		) {
			return $ip;
		}
	}
1132024
public function getBrand(ConnectionInterface $con = null)
    {
        if ($this->aBrand === null && ($this->brand_id !== null)) {
            $this->aBrand = BrandQuery::create()->findPk($this->brand_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aBrand->addDealerBrands($this);
             */
        }

        return $this->aBrand;
    }
32440
public function getDealerAdmin(ConnectionInterface $con = null)
    {
        if ($this->aDealerAdmin === null && ($this->id !== null)) {
            $this->aDealerAdmin = ChildDealerAdminQuery::create()->findPk($this->id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDealerAdmin->addDealerAdminVersions($this);
             */
        }

        return $this->aDealerAdmin;
    }
821382
protected function doUpdate(ConnectionInterface $con)
    {
        $selectCriteria = $this->buildPkeyCriteria();
        $valuesCriteria = $this->buildCriteria();

        return $selectCriteria->doUpdate($valuesCriteria, $con);
    }
1061157
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(PersonVersionTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(PersonVersionTableMap::FIRST_NAME)) {
            $modifiedColumns[':p' . $index++]  = 'FIRST_NAME';
        }
        if ($this->isColumnModified(PersonVersionTableMap::LAST_NAME)) {
            $modifiedColumns[':p' . $index++]  = 'LAST_NAME';
        }
        if ($this->isColumnModified(PersonVersionTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(PersonVersionTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }
        if ($this->isColumnModified(PersonVersionTableMap::VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION';
        }
        if ($this->isColumnModified(PersonVersionTableMap::VERSION_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_AT';
        }
        if ($this->isColumnModified(PersonVersionTableMap::VERSION_CREATED_BY)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_BY';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_TEAM_LINK_IDS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_TEAM_LINK_IDS';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_TEAM_LINK_VERSIONS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_TEAM_LINK_VERSIONS';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_IMAGE_IDS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_IMAGE_IDS';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_IMAGE_VERSIONS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_IMAGE_VERSIONS';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_FUNCTION_LINK_IDS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_FUNCTION_LINK_IDS';
        }
        if ($this->isColumnModified(PersonVersionTableMap::PERSON_FUNCTION_LINK_VERSIONS)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_FUNCTION_LINK_VERSIONS';
        }

        $sql = sprintf(
            'INSERT INTO person_version (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'FIRST_NAME':
                        $stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR);
                        break;
                    case 'LAST_NAME':
                        $stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION':
                        $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
                        break;
                    case 'VERSION_CREATED_AT':
                        $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION_CREATED_BY':
                        $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
                        break;
                    case 'PERSON_TEAM_LINK_IDS':
                        $stmt->bindValue($identifier, $this->person_team_link_ids, PDO::PARAM_STR);
                        break;
                    case 'PERSON_TEAM_LINK_VERSIONS':
                        $stmt->bindValue($identifier, $this->person_team_link_versions, PDO::PARAM_STR);
                        break;
                    case 'PERSON_IMAGE_IDS':
                        $stmt->bindValue($identifier, $this->person_image_ids, PDO::PARAM_STR);
                        break;
                    case 'PERSON_IMAGE_VERSIONS':
                        $stmt->bindValue($identifier, $this->person_image_versions, PDO::PARAM_STR);
                        break;
                    case 'PERSON_FUNCTION_LINK_IDS':
                        $stmt->bindValue($identifier, $this->person_function_link_ids, PDO::PARAM_STR);
                        break;
                    case 'PERSON_FUNCTION_LINK_VERSIONS':
                        $stmt->bindValue($identifier, $this->person_function_link_versions, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        $this->setNew(false);
    }
1018293
public function getDealer(ConnectionInterface $con = null)
    {
        if ($this->aDealer === null && ($this->dealer_id !== null)) {
            $this->aDealer = ChildDealerQuery::create()->findPk($this->dealer_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDealer->addDealerBrands($this);
             */
        }

        return $this->aDealer;
    }
229778
protected function getContext(ConnectionInterface $connection)
    {
        $context = array();
        if ($this->getForceIpv4Flag($connection)) {
            $context['bindto'] = '0.0.0.0:0';
        }
        $context = array('socket' => $context);
        return $context;
    }
639478
protected function getToken(ConnectionInterface $connection)
    {
        $token = null;

        if (isset($connection->Session) && $connection->Session) {
            foreach ($this->firewalls as $firewall) {
                if (false !== $serializedToken = $connection->Session->get('_security_'.$firewall, false)) {
                    /** @var TokenInterface $token */
                    $token = unserialize($serializedToken);

                    break;
                }
            }
        }

        if (null === $token) {
            $token = new AnonymousToken($this->firewalls[0], 'anon-'.$connection->WAMP->sessionId);
        }

        return $token;
    }