remove ray
This commit is contained in:
		@@ -81,11 +81,7 @@ class Form extends Component
 | 
				
			|||||||
        $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
 | 
					        $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->server->settings->server_timezone === '') {
 | 
					        if ($this->server->settings->server_timezone === '') {
 | 
				
			||||||
            ray($this->server->settings->server_timezone);
 | 
					 | 
				
			||||||
            ray('Server timezone is empty. Setting default timezone.');
 | 
					 | 
				
			||||||
            ray('Current timezone:', $this->server->settings->server_timezone);
 | 
					 | 
				
			||||||
            $defaultTimezone = config('app.timezone');
 | 
					            $defaultTimezone = config('app.timezone');
 | 
				
			||||||
            ray('Default timezone:', $defaultTimezone);
 | 
					 | 
				
			||||||
            $this->updateServerTimezone($defaultTimezone);
 | 
					            $this->updateServerTimezone($defaultTimezone);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -187,7 +183,6 @@ class Form extends Component
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function submit()
 | 
					    public function submit()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ray('Submit method called');
 | 
					 | 
				
			||||||
        if (isCloud() && !isDev()) {
 | 
					        if (isCloud() && !isDev()) {
 | 
				
			||||||
            $this->validate();
 | 
					            $this->validate();
 | 
				
			||||||
            $this->validate([
 | 
					            $this->validate([
 | 
				
			||||||
@@ -207,42 +202,27 @@ class Form extends Component
 | 
				
			|||||||
        $this->server->settings->wildcard_domain = $this->wildcard_domain;
 | 
					        $this->server->settings->wildcard_domain = $this->wildcard_domain;
 | 
				
			||||||
        $this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
 | 
					        $this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ray('Current timezone:', $this->server->settings->getOriginal('server_timezone'));
 | 
					 | 
				
			||||||
        ray('New timezone:', $this->server->settings->server_timezone);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $currentTimezone = $this->server->settings->getOriginal('server_timezone');
 | 
					        $currentTimezone = $this->server->settings->getOriginal('server_timezone');
 | 
				
			||||||
        $newTimezone = $this->server->settings->server_timezone;
 | 
					        $newTimezone = $this->server->settings->server_timezone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ray('Comparing timezones:', $currentTimezone, $newTimezone);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($currentTimezone !== $newTimezone || $currentTimezone === '') {
 | 
					        if ($currentTimezone !== $newTimezone || $currentTimezone === '') {
 | 
				
			||||||
            ray('Timezone change detected');
 | 
					 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                ray('Calling updateServerTimezone');
 | 
					 | 
				
			||||||
                $timezoneUpdated = $this->updateServerTimezone($newTimezone);
 | 
					                $timezoneUpdated = $this->updateServerTimezone($newTimezone);
 | 
				
			||||||
                ray('updateServerTimezone result:', $timezoneUpdated);
 | 
					 | 
				
			||||||
                if ($timezoneUpdated) {
 | 
					                if ($timezoneUpdated) {
 | 
				
			||||||
                    $this->server->settings->server_timezone = $newTimezone;
 | 
					                    $this->server->settings->server_timezone = $newTimezone;
 | 
				
			||||||
                    $this->server->settings->save();
 | 
					                    $this->server->settings->save();
 | 
				
			||||||
                    ray('New timezone saved to database:', $newTimezone);
 | 
					 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    ray('Timezone update failed');
 | 
					 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (\Exception $e) {
 | 
					            } catch (\Exception $e) {
 | 
				
			||||||
                ray('Exception in updateServerTimezone:', $e->getMessage());
 | 
					 | 
				
			||||||
                $this->dispatch('error', 'Failed to update server timezone: ' . $e->getMessage());
 | 
					                $this->dispatch('error', 'Failed to update server timezone: ' . $e->getMessage());
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            ray('No timezone change detected');
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ray('Saving server settings');
 | 
					 | 
				
			||||||
        $this->server->settings->save();
 | 
					        $this->server->settings->save();
 | 
				
			||||||
        $this->server->save();
 | 
					        $this->server->save();
 | 
				
			||||||
        $this->dispatch('success', 'Server updated.');
 | 
					        $this->dispatch('success', 'Server updated.');
 | 
				
			||||||
        ray('Submit method completed');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function updatedServerTimezone($value)
 | 
					    public function updatedServerTimezone($value)
 | 
				
			||||||
@@ -257,7 +237,6 @@ class Form extends Component
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private function updateServerTimezone($desired_timezone)
 | 
					    private function updateServerTimezone($desired_timezone)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ray('updateServerTimezone called with value:', $desired_timezone);
 | 
					 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $commands = [
 | 
					            $commands = [
 | 
				
			||||||
                "if command -v timedatectl > /dev/null 2>&1 && pidof systemd > /dev/null; then",
 | 
					                "if command -v timedatectl > /dev/null 2>&1 && pidof systemd > /dev/null; then",
 | 
				
			||||||
@@ -290,12 +269,8 @@ class Form extends Component
 | 
				
			|||||||
                "date"
 | 
					                "date"
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ray('Commands to be executed:', $commands);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
            $result = instant_remote_process($commands, $this->server);
 | 
					            $result = instant_remote_process($commands, $this->server);
 | 
				
			||||||
            ray('Result of instant_remote_process:', $result);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Improved verification
 | 
					 | 
				
			||||||
            $verificationCommands = [
 | 
					            $verificationCommands = [
 | 
				
			||||||
                "readlink /etc/localtime | sed 's#/usr/share/zoneinfo/##'",
 | 
					                "readlink /etc/localtime | sed 's#/usr/share/zoneinfo/##'",
 | 
				
			||||||
                "date +'%Z %:z'"
 | 
					                "date +'%Z %:z'"
 | 
				
			||||||
@@ -304,7 +279,6 @@ class Form extends Component
 | 
				
			|||||||
            $verificationLines = explode("\n", trim($verificationResult));
 | 
					            $verificationLines = explode("\n", trim($verificationResult));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (count($verificationLines) !== 2) {
 | 
					            if (count($verificationLines) !== 2) {
 | 
				
			||||||
                ray('Unexpected verification result:', $verificationResult);
 | 
					 | 
				
			||||||
                $this->dispatch('error', 'Failed to verify timezone update. Unexpected server response.');
 | 
					                $this->dispatch('error', 'Failed to verify timezone update. Unexpected server response.');
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -312,27 +286,19 @@ class Form extends Component
 | 
				
			|||||||
            $actualTimezone = trim($verificationLines[0]);
 | 
					            $actualTimezone = trim($verificationLines[0]);
 | 
				
			||||||
            [$abbreviation, $offset] = explode(' ', trim($verificationLines[1]));
 | 
					            [$abbreviation, $offset] = explode(' ', trim($verificationLines[1]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Convert desired_timezone to DateTimeZone for comparison
 | 
					 | 
				
			||||||
            $desiredTz = new \DateTimeZone($desired_timezone);
 | 
					            $desiredTz = new \DateTimeZone($desired_timezone);
 | 
				
			||||||
            $desiredAbbr = (new \DateTime('now', $desiredTz))->format('T');
 | 
					            $desiredAbbr = (new \DateTime('now', $desiredTz))->format('T');
 | 
				
			||||||
            $desiredOffset = $this->formatOffset($desiredTz->getOffset(new \DateTime('now', $desiredTz)));
 | 
					            $desiredOffset = $this->formatOffset($desiredTz->getOffset(new \DateTime('now', $desiredTz)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Compare actual timezone, abbreviation, and offset with the desired timezone
 | 
					 | 
				
			||||||
            if ($actualTimezone === $desired_timezone && $abbreviation === $desiredAbbr && $offset === $desiredOffset) {
 | 
					            if ($actualTimezone === $desired_timezone && $abbreviation === $desiredAbbr && $offset === $desiredOffset) {
 | 
				
			||||||
                ray('Timezone update verified successfully');
 | 
					 | 
				
			||||||
                $this->server->settings->server_timezone = $desired_timezone;
 | 
					                $this->server->settings->server_timezone = $desired_timezone;
 | 
				
			||||||
                $this->server->settings->save();
 | 
					                $this->server->settings->save();
 | 
				
			||||||
                ray('Server settings updated');
 | 
					 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                ray('Timezone verification failed. Expected:', $desired_timezone, 'Actual:', $actualTimezone);
 | 
					 | 
				
			||||||
                ray('Expected abbreviation:', $desiredAbbr, 'Actual:', $abbreviation);
 | 
					 | 
				
			||||||
                ray('Expected offset:', $desiredOffset, 'Actual:', $offset);
 | 
					 | 
				
			||||||
                $this->dispatch('error', 'Failed to update server timezone. The server reported a different timezone than requested.');
 | 
					                $this->dispatch('error', 'Failed to update server timezone. The server reported a different timezone than requested.');
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            ray('Exception caught:', $e->getMessage());
 | 
					 | 
				
			||||||
            $this->dispatch('error', 'Failed to update server timezone: ' . $e->getMessage());
 | 
					            $this->dispatch('error', 'Failed to update server timezone: ' . $e->getMessage());
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user