HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpwatermates/wp-content/plugins/wp-google-maps/includes/class.upgrader.php
<?php

namespace WPGMZA;

class Upgrader
{
	public function upgrade($fromVersion)
	{
		// NB: We don't use the global plugin object here because it's not initialised yet
		$settings = new GlobalSettings();
		
		if(preg_match('/^7\./', $fromVersion)) {
			// Legacy style for upgrading users
			$settings->user_interface_style = "legacy";
		}

		if(preg_match('/^8\./', $fromVersion)) {
			// Legacy build for users upgrading (They will be prompted to switch if they want to)
			$settings->internal_engine = "legacy";
		}
		
		add_action('init', function() {
			global $wpgmza;

    		/* Developer Hook (Action) - Run additional actions as part of an upgrade */ 
			do_action("wpgmza_base_upgrade_hook");

			$wpgmza->updateAllMarkerXMLFiles();
		});
		
		if($this->assertVersionTag($fromVersion)){
			/* Only run version compares if the versio number was asserted */ 
			if(version_compare($fromVersion, '7.00', '<')){
				add_action('init', array($this, 'migrateV7SpatialData'), 1, 11);
			}

			if(version_compare($fromVersion, '8.1.0', '<')){
				add_action('init', array($this, 'migrateCircleData'), 1, 11);
			}

			if(version_compare($fromVersion, '8.1.12', '<')){
				add_action('init', array($this, 'removeMarkerLngLatColumn'), 1, 11);
			}
		}

	}

	public function assertVersionTag($version){
		if(!empty(floatval($version))){
			/* Value was parsed */
			return true;
		}
		return false;
	}

	public function removeMarkerLngLatColumn(){
		global $wpgmza;
		global $wpdb;
		global $wpgmza_tblname;

		if($wpdb->get_var("SHOW COLUMNS FROM ".$wpgmza_tblname." LIKE 'lnglat'")){
			$wpdb->query('ALTER TABLE '.$wpgmza_tblname.' DROP COLUMN lnglat');
		}  
	}
	
	public function migrateV7SpatialData()
	{
		global $wpgmza;
		global $wpdb;
		global $wpgmza_tblname;
		
		if(!$wpdb->get_var("SHOW COLUMNS FROM ".$wpgmza_tblname." LIKE 'latlng'"))
			$wpdb->query('ALTER TABLE '.$wpgmza_tblname.' ADD latlng POINT');
		
		if($wpdb->get_var("SELECT COUNT(id) FROM $wpgmza_tblname WHERE latlng IS NULL LIMIT 1") == 0)
			return; // Nothing to migrate
		
		$wpdb->query("UPDATE ".$wpgmza_tblname." SET latlng={$wpgmza->spatialFunctionPrefix}PointFromText(CONCAT('POINT(', CAST(lat AS DECIMAL(18,10)), ' ', CAST(lng AS DECIMAL(18,10)), ')'))");
	}

	public function migrateCircleData()
	{
		global $wpgmza;
		global $wpdb;
		global $WPGMZA_TABLE_NAME_CIRCLES;

		if($wpdb->get_var("SHOW TABLES LIKE '{$WPGMZA_TABLE_NAME_CIRCLES}'") !== $WPGMZA_TABLE_NAME_CIRCLES){
			return; // Nothing to migrate			
		}
		
		$wpdb->query("UPDATE {$WPGMZA_TABLE_NAME_CIRCLES} SET radius = radius / 1000");
	}
}