Get Project-X remote environments.

@return array
An array of remote environments, keyed by realm.
775974
public static function getRemoteEnvironments()
    {
        $environments = [];

        foreach (self::getProjectConfig()->getRemote() as $remote) {
            foreach ($remote as $environment) {
                if (!isset($environment['realm'])) {
                    continue;
                }
                $realm = $environment['realm'];
                unset($environment['realm']);

                $environments[$realm][] = $environment;
            }
        }

        return $environments;
    }
821844
function getProjects() {
		$getUserProjectsRequest = new getUserProjects ();
		$getUserProjectsRequest->isSubProjectIncluded = TRUE;
		$projects = $this->projectService->getUserProjects ( $getUserProjectsRequest )->return;

		$i = 0;
		$proj_arr = array ();
		if (is_array ( $projects )) {
			foreach ( $projects as $project ) {
				$pdproject = new PDProject ( $project );
				$proj_arr [$i ++] = $pdproject;
			}
		} else {
			$fullProject = $this->getProject ( $projects->projectInfo->shortCode );
			$proj_arr [0] = $fullProject;
		}
		
		return $proj_arr;
	}
484637
public static function parseAllEnvironmentParameters(): array
	{
		$parameters = [];
		foreach ($_SERVER as $key => $value) {
			// Ensure value
			$value = getenv($key);
			if ($value !== false) {
				$parameters[$key] = $value;
			}
		}

		return $parameters;
	}
1269957
public function getEnabledProjects()
    {
        return array_filter($this->codex->projects->all(), function(Project $project){
            return $project->config('git.enabled', false) === true;
        });
    }
452965
public function getIPs()
	{
		(isset($_SERVER['HTTP_CLIENT_IP'])) ? $httpClientIp = $_SERVER['HTTP_CLIENT_IP'] : $httpClientIp = Null;
		(isset($_SERVER['REMOTE_ADDR'])) ? $remoteAddr = $_SERVER['REMOTE_ADDR'] : $remoteAddr = Null;
		(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $httpForwardedFor = $_SERVER['HTTP_X_FORWARDED_FOR'] : $httpForwardedFor = Null;
		$allIPs = array( $httpClientIp, $remoteAddr, $httpForwardedFor );
		$IPs 		= $this->checkIPs($allIPs);
		return $IPs;
	}
1204181
protected function getCurrentPlatform()
    {
        $env = [];

        $container = new Container('melisinstaller');
        if (isset($container['environments']) && isset($container['environments']['default_environment'])) {
            $env = $container['environments']['default_environment'];
        }

        return $env;
    }
160235
protected function projectsStatus()
    {
        $status_report = [];
        $status = locale_translation_get_status();
        foreach ($status as $project_id => $project) {
            foreach ($project as $langcode => $project_info) {
                $info = '';
                if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
                    $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null;
                    $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null;
                    $local_age = $local->timestamp? format_date($local->timestamp, 'html_date'): '';
                    $remote_age = $remote->timestamp? format_date($remote->timestamp, 'html_date'): '';

                    if ($local_age >= $remote_age) {
                        $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
                    } else {
                        $info = $this->trans('commands.locale.translation.status.messages.translation-project-available');
                    }
                } elseif ($project_info->type == LOCALE_TRANSLATION_CURRENT) {
                    $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
                } else {
                    $local_age = '';
                    $remote_age = '';
                    $info = $this->createInfoString($project_info);
                }

                $status_report[$langcode][] = [$project_info->name, $project_info->version, $local_age, $remote_age ,$info ];
            }
        }

        return $status_report;
    }
1211170
public function getCurrentRealmsAffections(): array
    {
        $realmsAffections = [];
        foreach ($this->getRealmsAffectionsSum() as $periodName => $periodSum) {
            $realmsAffections[$periodName] = new RealmsAffection([$periodSum, $periodName]);
        }

        return $realmsAffections;
    }
509468
public static function EnvironmentDetectByIps () {
		if (static::$environment === NULL) {
			$request = & \MvcCore\Application::GetInstance()->GetRequest();
			$serverAddress = $request->GetServerIp();
			$remoteAddress = $request->GetClientIp();
			if ($serverAddress == $remoteAddress) {
				static::$environment = static::ENVIRONMENT_DEVELOPMENT;
			} else {
				static::$environment = static::ENVIRONMENT_PRODUCTION;
			}
		}
		return static::$environment;
	}
1245983
public function getVirtualHostsAsArray()
    {

        // prepare the array containing the virtual host configuration
        $virtualHosts = array();

        // iterate hosts
        /** @var \AppserverIo\Appserver\Core\Api\Node\VirtualHostNode $virtualHost */
        foreach ($this->getVirtualHosts() as $virtualHost) {
            // explode the virtual host names
            $virtualHostNames = explode(' ', $virtualHost->getName());

            // Some virtual hosts might have an extensionType to expand their name attribute, check for that
            if ($virtualHost->hasInjector()) {
                $virtualHostNames = array_merge($virtualHostNames, explode(' ', $virtualHost->getInjection()));
            }

            // prepare the virtual hosts
            foreach ($virtualHostNames as $virtualHostName) {
                // set all virtual hosts params per key for faster matching later on
                $virtualHosts[trim($virtualHostName)] = array(
                    'params' => $virtualHost->getParamsAsArray(),
                    'headers' => $virtualHost->getHeadersAsArray(),
                    'rewriteMaps' => $virtualHost->getRewriteMapsAsArray(),
                    'rewrites' => $virtualHost->getRewritesAsArray(),
                    'environmentVariables' => $virtualHost->getEnvironmentVariablesAsArray(),
                    'accesses' => $virtualHost->getAccessesAsArray(),
                    'locations' => $virtualHost->getLocationsAsArray(),
                    'authentications' => $virtualHost->getAuthenticationsAsArray(),
                    'analytics' => $virtualHost->getAnalyticsAsArray()
                );
            }
        }

        // return the virtual host configuration
        return $virtualHosts;
    }
1349627
private static function _remoteIP()
    {
        // Catch all possible hints of the client's IP address, not just REMOTE_ADDR
        foreach (
            array(
                'HTTP_CLIENT_IP',
                'HTTP_X_FORWARDED_FOR',
                'HTTP_X_FORWARDED',
                'HTTP_X_CLUSTER_CLIENT_IP',
                'HTTP_FORWARDED_FOR',
                'HTTP_FORWARDED',
                'REMOTE_ADDR'
            )
            as $key
        ) {
            if (array_key_exists($key, $_SERVER)) {
                foreach (dejoin(',', $_SERVER[$key]) as $ip) {
                    if (filter_var($ip, FILTER_VALIDATE_IP)) {
                        // Return the first one found
                        return $ip;
                    };
                };
            };
        };
        return null;
    }
896239
public function getBrowsers()
	{
		if( !$this->_open )
		{
			trigger_error( "Log File not read", E_USER_ERROR );
			return array();
		}
		$remote_addrs	= array();	
		$browsers		= array();
		foreach( $this->data as $entry )
		{
			if( $entry['remote_addr'] != $this->skip && $entry['http_user_agent'] )
			{
				if( isset( $remote_addrs[$entry['remote_addr']] ) )
				{
					if( $remote_addrs[$entry['remote_addr']] < $entry['timestamp'] - 30 * 60 )
					{
						if( isset( $browsers[$entry['http_user_agent']] ) )
							$browsers[$entry['http_user_agent']] ++;
						else
							$browsers[$entry['http_user_agent']]	= 1;
					}
					$remote_addrs[$entry['remote_addr']]	= $entry['timestamp'];
				}
				else
				{
					if( isset( $browsers[$entry['http_user_agent']] ) )
						$browsers[$entry['http_user_agent']] ++;
					else
						$browsers[$entry['http_user_agent']]	= 1;
					$remote_addrs[$entry['remote_addr']]	= $entry['timestamp'];
				}
			}
		}
		arsort( $browsers );
		$lines	= array();
		foreach( $browsers as $browser => $count )
			$lines[]	= "<tr><td>".$browser."</td><td>".$count."</td></tr>";
		$lines		= implode( "\n\t", $lines );
		$content	= "<table>".$lines."</table>";
		return $content;
	}
1348598
public function getProjects($reset = false)
    {
        $data = $this->getAccountInfo($reset);
        $client = $this->connector->getClient();
        $projects = [];
        foreach ($data['projects'] as $project) {
            // Each project has its own endpoint on a Platform.sh region.
            $projects[] = new Project($project, $project['endpoint'], $client);
        }

        return $projects;
    }
336741
public function getIp()
    {
        $keys = array('X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR');
        foreach ($keys as $key) {
            if (isset($this->env[$key])) {
                return $this->env[$key];
            }
        }

        return $this->env['REMOTE_ADDR'];
    }
442176
private static function _getRemoteRepositories()
	{
		self::_init();
		if (!self::$remoteRepositories)
		{
			self::$remoteRepositories = self::_getRepositoryManager()->getRepositories();
		}
		return self::$remoteRepositories;
	}
138215
public function getRevManifest(): array {
        if (is_null(self::$_revManifest)) {
            $manifestPath = APPLICATION_PATH . '/../rev-manifest-' . APPLICATION_ENV . '.json';
            self::$_revManifest = file_exists($manifestPath)
                ? json_decode(file_get_contents($manifestPath), true)
                : [];
        }
        return self::$_revManifest;
    }
447828
protected function getMergedEnvironments($base)
    {
        $projectRoot = $this->getProjectRoot();
        if (!$projectRoot) {
            throw new RootNotFoundException();
        }

        /** @var \Platformsh\Cli\Service\Git $git */
        $git = $this->getService('git');
        $git->setDefaultRepositoryDir($projectRoot);

        /** @var \Platformsh\Cli\Local\LocalProject $localProject */
        $localProject = $this->getService('local.project');
        $localProject->ensureGitRemote($projectRoot, $this->getSelectedProject()->getGitUrl());

        $remoteName = $this->config()->get('detection.git_remote_name');

        // Find a list of branches merged on the remote.
        $git->fetch($remoteName);
        $mergedBranches = $git->getMergedBranches($remoteName . '/' . $base, true);
        $mergedBranches = array_filter($mergedBranches, function ($mergedBranch) use ($remoteName, $base) {
            return strpos($mergedBranch, $remoteName) === 0;
        });
        $stripLength = strlen($remoteName . '/');
        $mergedBranches = array_map(function ($mergedBranch) use ($stripLength) {
            return substr($mergedBranch, $stripLength);
        }, $mergedBranches);

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

        // Reconcile this with the list of environments from the API.
        $environments = $this->api()->getEnvironments($this->getSelectedProject(), true);
        $mergedEnvironments = array_intersect_key($environments, array_flip($mergedBranches));
        unset($mergedEnvironments[$base], $mergedEnvironments['master']);
        $parent = $environments[$base]['parent'];
        if ($parent) {
            unset($mergedEnvironments[$parent]);
        }

        return $mergedEnvironments;
    }