HEX
Server: Apache/2.4.57 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.2
System: Linux vmi267337.contaboserver.net 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
User: ohirex (1008)
PHP: 8.2.8
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec
Upload Files
File: /home/ohirex/web/ohirex.com/public_html/wp-content/plugins/mailster/classes/libs/static.map.php
<?php

use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;
use \DantSu\OpenStreetMapStaticAPI\TileLayer;

class MailsterStaticMap {

	protected $openStreetMap;
	protected $file;
	protected $exist;

	public function __construct( $args ) {


		$coords = array();
		if ( isset( $args['coords'] ) ) {
			foreach ( $args['coords'] as $c ) {
				if ( is_string( $c ) ) {
					$c        = explode( ',', $c );
					$coords[] = new LatLng( (float) $c[0], (float) $c[1] );
				}
			}
		}

		if ( isset( $args['lat'] ) && isset( $args['lon'] ) ) {
			$coords[] = new LatLng( (float) $args['lat'], (float) $args['lon'] );
		}

		$center = $this->getCenter( $coords );

		$zoom        = (int) $args['zoom'];
		$imageWidth  = (int) $args['width'];
		$imageHeight = (int) $args['height'];
		//$zoom        = $this->getZoom( $coords, $imageWidth, $imageHeight, (int) $args['zoom'] );
		$tileServer  = new TileLayer( 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', '© OpenStreetMap' );

		$this->openStreetMap = new OpenStreetMap( $center, $zoom, $imageWidth, $imageHeight, $tileServer );

		foreach ( $coords as $markerpos ) {
			$this->openStreetMap->addMarkers(
				( new Markers( MAILSTER_DIR . 'assets/img/osm/markers/marker.png' ) )
				->setAnchor( Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM )
				->addMarker( $markerpos )
			);
		}
	}

	private function getCenter( $coords ) {

		if ( ! is_array( $coords ) ) {
			return false;
		}

		$num_coords = count( $coords );

		if ( $num_coords == 1 ) {
			return $coords[0];
		}

		$X = 0.0;
		$Y = 0.0;
		$Z = 0.0;

		foreach ( $coords as $coord ) {
			$lat = $coord->getLat() * pi() / 180;
			$lon = $coord->getLng() * pi() / 180;

			$a = cos( $lat ) * cos( $lon );
			$b = cos( $lat ) * sin( $lon );
			$c = sin( $lat );

			$X += $a;
			$Y += $b;
			$Z += $c;
		}

		$X /= $num_coords;
		$Y /= $num_coords;
		$Z /= $num_coords;

		$lon = atan2( $Y, $X );
		$hyp = sqrt( $X * $X + $Y * $Y );
		$lat = atan2( $Z, $hyp );

		return new LatLng( $lat * 180 / pi(), $lon * 180 / pi() );
	}


	public function getDir() {
		return $this->file;
	}

	public function getUrl() {
		$dir = $this->getDir();
		return str_replace( MAILSTER_UPLOAD_DIR, MAILSTER_UPLOAD_URI, $dir );
	}

	public function getFile() {

	}

	public function displayPNG() {
		$this->openStreetMap->getImage()->displayPNG();
	}



}