Working Update Function!
This commit is contained in:
		@@ -10,7 +10,7 @@ use ManiaControl\Players\Player;
 | 
				
			|||||||
use ManiaControl\Players\PlayerManager;
 | 
					use ManiaControl\Players\PlayerManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Class checking for ManiaControl Core and Plugin Updates
 | 
					 * Manager checking for ManiaControl Core and Plugin Updates
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author steeffeen & kremsy
 | 
					 * @author steeffeen & kremsy
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -132,7 +132,11 @@ class UpdateManager implements CallbackListener, CommandListener {
 | 
				
			|||||||
			$this->maniaControl->authenticationManager->sendNotAllowed($player);
 | 
								$this->maniaControl->authenticationManager->sendNotAllowed($player);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		$updateData = $this->checkCoreUpdate();
 | 
							$updateData = $this->checkCoreUpdate(true);
 | 
				
			||||||
 | 
							if (!$updateData) {
 | 
				
			||||||
 | 
								$this->maniaControl->chat->sendError('Update is currently not possible!', $player->login);
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		$this->maniaControl->chat->sendInformation("Starting Update to Version v{$updateData->version}...", $player->login);
 | 
							$this->maniaControl->chat->sendInformation("Starting Update to Version v{$updateData->version}...", $player->login);
 | 
				
			||||||
		$performBackup = $this->maniaControl->settingManager->getSetting($this, self::SETTING_PERFORM_BACKUPS);
 | 
							$performBackup = $this->maniaControl->settingManager->getSetting($this, self::SETTING_PERFORM_BACKUPS);
 | 
				
			||||||
		if ($performBackup && !$this->performBackup()) {
 | 
							if ($performBackup && !$this->performBackup()) {
 | 
				
			||||||
@@ -175,16 +179,16 @@ class UpdateManager implements CallbackListener, CommandListener {
 | 
				
			|||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * @return mixed
 | 
						 * @return mixed
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private function checkCoreUpdate() {
 | 
						private function checkCoreUpdate($ignoreVersion = false) {
 | 
				
			||||||
		$updateChannel = $this->getCurrentUpdateChannelSetting();
 | 
							$updateChannel = $this->getCurrentUpdateChannelSetting();
 | 
				
			||||||
		$url = self::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel;
 | 
							$url = self::URL_WEBSERVICE . 'versions?update=1¤t=1&channel=' . $updateChannel;
 | 
				
			||||||
		$dataJson = file_get_contents($url);
 | 
							$dataJson = file_get_contents($url);
 | 
				
			||||||
		$versions = json_decode($dataJson);
 | 
							$versions = json_decode($dataJson);
 | 
				
			||||||
		if (!$versions || !isset($versions[0])) {
 | 
							if (!$versions || !isset($versions[0])) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		$updateData = $versions[0];
 | 
							$updateData = $versions[0];
 | 
				
			||||||
		if ($updateData->version <= ManiaControl::VERSION) {
 | 
							if (!$ignoreVersion && $updateData->version <= ManiaControl::VERSION) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return $updateData;
 | 
							return $updateData;
 | 
				
			||||||
@@ -275,7 +279,7 @@ class UpdateManager implements CallbackListener, CommandListener {
 | 
				
			|||||||
			trigger_error("Couldn't open Update Zip. ({$result})");
 | 
								trigger_error("Couldn't open Update Zip. ({$result})");
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		$zip->extractTo(ManiaControlDir . '/test/');
 | 
							$zip->extractTo(ManiaControlDir);
 | 
				
			||||||
		$zip->close();
 | 
							$zip->close();
 | 
				
			||||||
		unlink($updateFileName);
 | 
							unlink($updateFileName);
 | 
				
			||||||
		@rmdir($tempDir);
 | 
							@rmdir($tempDir);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user