jsCallback('Dateiuploads konnten nicht verarbeitet werden!', true); die; } if (md5_file($originalFile) != _ORIGINAL_MD5) { jsCallback('Die hochgeladene Originaldatei entspricht keiner gültigen Version 371568!'); die; } if ($_FILES['source']['tmp_name'] == '') { copy($originalFile, $sourceFile); } if (_SCOTTYCHECK == true && Patcher::checkForScottyFile($sourceFile)) { jsCallback('Dies ist ein File von Scotty und ist nicht für Patches freigegeben!'); die; } $maps = PatchLocator::getMaps('R60_2005'); $patcher = new Patcher(); foreach ($_POST['setting'] as $mapName => $settingVal) { if ($settingVal == $mapName . '0' && !array_key_exists('overwriteOriginal', $_POST)) { continue; } $mod = new Modification($maps[$mapName], $maps[$mapName]->getSetting($settingVal)); $patcher->addModification($mod); } $presetString = ''; $presetMap = _PRESET_MAPPING(); foreach ($presetMap as $preset) { if (!array_key_exists($preset, $_POST['setting'])) { $presetString = ''; break; } $presetString .= str_replace($preset, '', $_POST['setting'][$preset]);
public function testPatchTablePatchAll() { $repo = $this->createRepository(); $query = $this->createQuery(); $handle = $this->createFileHandle(); $fileMap = $this->createMap(); $dbMap = $this->createMap(); $filterFactory = $this->createFilterFactory(); $installRepository = $this->createInstallRepository(); $installer = $this->createInstaller(); $install = $this->createInstall(); $table = 'someTable'; $queryString = 'someQuery'; $error = ['something 0', 'something 1', null]; $dbCollection = $this->createCollection(); $fileCollection = $this->createCollection(); $handle->expects($this->once())->method('getAllFilesInDir')->will($this->returnValue([$table])); $repo->expects($this->exactly(2))->method('buildPatchesFromDatabase')->with($this->equalTo($table))->will($this->returnValue($dbCollection)); $repo->expects($this->once())->method('buildPatchesFromFile')->with($this->equalTo($table))->will($this->returnValue($fileCollection)); $installRepository->expects($this->once())->method('buildInstallFromFile')->with($this->equalTo($table))->will($this->returnValue($install)); $findUnmatched = $this->createCallable(); $filterFactory->expects($this->once())->method('findUnmatched')->with($this->equalTo($dbCollection))->will($this->returnValue($findUnmatched)); $findAfterInstall = $this->createCallable(); $filterFactory->expects($this->once())->method('findAfterInstall')->with($this->equalTo($install))->will($this->returnValue($findAfterInstall)); $unmatched = $this->createCollection(); $fileCollection->expects($this->once())->method('findAll')->with($this->equalTo($findUnmatched))->will($this->returnValue($unmatched)); $unmatchedAfterInstall = $this->createCollection(); $unmatched->expects($this->once())->method('findAll')->with($this->equalTo($findAfterInstall))->will($this->returnValue($unmatchedAfterInstall)); $patch = $this->createPatch(); $patch->expects($this->once())->method('getQuery')->will($this->returnValue($queryString)); $query->expects($this->once())->method('patch')->with($this->equalTo($queryString))->will($this->returnValue($error)); $unmatchedAfterInstall->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$patch]))); $dbMap->expects($this->once())->method('applyPatch')->with($this->equalTo($patch)); $fileMap->expects($this->once())->method('applyPatch')->with($this->equalTo($patch)); $installer->expects($this->once())->method('updateInstallScripts')->with($this->equalTo($install), $this->equalTo($dbCollection)); $controller = new Patcher($repo, $filterFactory, $query, $handle, $dbMap, $fileMap, $installRepository, $installer); $controller->patchAll(); }
$rangesCount = $section[_RANGESCOUNT]; for ($i = 1; $i <= $rangesCount; $i++) { if (!array_key_exists('Range' . $i . 'Start', $section) || !array_key_exists('Range' . $i . 'End', $section)) { throw new Exception('RangesCount differs from actual number of ranges'); } $range = new Range($section['Range' . $i . 'Start'], $section['Range' . $i . 'End']); $map->addRange($range); } break; default: $setting = new Setting($sectionName, $section[_DESCRIPTION], $section[_LISTENTRY], array()); foreach ($section as $key => $value) { if ($key == _DESCRIPTION || $key == _LISTENTRY) { continue; } $value = new Value($key, $value); $setting->addValue($value); } $map->addSetting($setting); break; } } $maps[] = $map; } $settingKeys = $maps[0]->getSettingKeys(); $mod1 = new Modification($maps[0], $maps[0]->getSetting($settingKeys[1])); $patcher = new Patcher(); $patcher->addModification($mod1); echo "<pre>"; $patcher->createTunedFile(_DIRECTORY . 'original.rom', _DIRECTORY . 'original.rom'); echo "</pre>";