/** * @public * * Backup einer Datei erzeugen * * @param string $sourceFile Datei die gesichert werden soll * @param string $backupFile Ziel Datei */ public function CreateBackupFromFile($sourceFile, $backupFile) { $fileHandler = new IPSFileHandler(); if (file_exists($sourceFile)) { $fileHandler->CopyFile($sourceFile, $backupFile); } else { $this->logHandler->Debug('Backup NOT possible - Source File '.$sourceFile.' doesnt exists'); } }
/** * @public * * Erzeugt das File KnownModules */ public function BuildKnownModules() { $knownRepositories = $this->GetKnownRepositories(); $knownModules = array(); $repositoryVersions = array(); $changeList = array(); $requiredModules = array(); foreach ($knownRepositories as $repositoryIdx=>$repository) { echo 'Process Repsoitory '.$repository.PHP_EOL; $fileHandler = new IPSFileHandler(); $repository = IPSFileHandler::AddTrailingPathDelimiter($repository); $localAvailableModuleList = sys_get_temp_dir().'\\AvailableModules.ini'; $repositoryAvailableModuleList = $repository.'IPSLibrary\\config\\AvailableModules.ini'; $fileHandler->CopyFiles(array($repositoryAvailableModuleList), array($localAvailableModuleList)); $availableModules = parse_ini_file($localAvailableModuleList, true); foreach ($availableModules as $moduleName=>$moduleData) { $moduleProperties = explode('|',$moduleData); $modulePath = $moduleProperties[0]; $moduleDescription = ''; if (array_key_exists(1, $moduleProperties)) { $moduleDescription = $moduleProperties[1]; } $localDownloadIniFile = sys_get_temp_dir().'\\DownloadListfile.ini'; $repositoryDownloadIniFile = $repository.'IPSLibrary\\install\\DownloadListFiles\\'.$moduleName.'_FileList.ini'; $result = $fileHandler->CopyFiles(array($repositoryDownloadIniFile), array($localDownloadIniFile), false); if ($result===false) { echo ' '.$moduleName.'could NOT be found in '.$repository.PHP_EOL; } else { echo ' Processing '.$moduleName.' in '.$repository.PHP_EOL; $configHandler = new IPSIniConfigHandler($localDownloadIniFile); $availableVersion = $configHandler->GetValue(IPSConfigHandler::SCRIPTVERSION); $changeListModule = $configHandler->GetValueDef(IPSConfigHandler::CHANGELIST, null, array()); $requiredModulesOfModule = $configHandler->GetValueDef(IPSConfigHandler::REQUIREDMODULES, null, array()); $replaceModule = false; if (!array_key_exists($moduleName, $knownModules)) { $replaceModule = true; } elseif ($versionHandler->CompareVersionsNewer($knownModules[$moduleName]['Version'], $availableVersion)) { $replaceModule = true; } elseif ($versionHandler->CompareVersionsEqual($knownModules[$moduleName]['Version'], $availableVersion) and $versionHandler->IsModuleInstalled($moduleName)) { $versionHandler = new IPSFileVersionHandler($moduleName); if ($versionHandler->GetModuleRepository()==$repository) { $replaceModule = true; } } else { } if ($replaceModule) { $knownModules[$moduleName]['Version'] = $availableVersion; $knownModules[$moduleName]['Repository'] = $repository; $knownModules[$moduleName]['Description'] = $moduleDescription; $knownModules[$moduleName]['Path'] = $modulePath; if ($this->IsModuleInstalled($moduleName)) { $versionHandler = new IPSFileVersionHandler($moduleName); } $knownModules[$moduleName]['LastRepository'] = $versionHandler->GetModuleRepository(); $changeList[$moduleName] = $changeListModule; $requiredModules[$moduleName] = $requiredModulesOfModule; } $repositoryVersions[$moduleName][$repository] = $availableVersion; } } } $fileContent = ''; foreach ($knownModules as $moduleName=>$moduleData) { $fileContent .= '['.$moduleName.']'.PHP_EOL; foreach ($moduleData as $property=>$value) { // "//192.168..." not handled correct in case of usage "" if ($property=='Repository') { $fileContent .= $property.'='.$value.''.PHP_EOL; } else { $fileContent .= $property.'="'.$value.'"'.PHP_EOL; } } } file_put_contents($this->fileNameKnownModules, $fileContent); $fileContent = ''; foreach ($repositoryVersions as $moduleName=>$moduleData) { $fileContent .= '['.$moduleName.']'.PHP_EOL; foreach ($moduleData as $property=>$value) { $fileContent .= $property.'="'.$value.'"'.PHP_EOL; } } file_put_contents($this->fileNameRepositoryVersions, $fileContent); $fileContent = ''; foreach ($changeList as $moduleName=>$moduleData) { $fileContent .= '['.$moduleName.']'.PHP_EOL; foreach ($moduleData as $property=>$value) { $fileContent .= $property.'="'.$value.'"'.PHP_EOL; } } file_put_contents($this->fileNameChangeList, $fileContent); $fileContent = ''; foreach ($requiredModules as $moduleName=>$moduleData) { $fileContent .= '['.$moduleName.']'.PHP_EOL; foreach ($moduleData as $property=>$value) { $fileContent .= $property.'="'.$value.'"'.PHP_EOL; } } file_put_contents($this->fileNameRequiredModules, $fileContent); $this->LoadFileKnownModules(); $this->LoadFileRepositoryVersions(); $this->LoadFileChangeList(); $this->LoadFileRequiredModules(); }
/** * @public * * Die Funktion registriert eine Liste von User Files anhand ihres Degfault Filenames und Directory Pfades in IPS * * @param string $defaultScriptList Liste von Scripts, die registriert werden soll */ public function RegisterUserScriptsListByDefaultFilename($defaultScriptList) { $scriptList = array(); foreach ($defaultScriptList as $idx=>$defaultScript) { $scriptList[] = IPSFileHandler::GetUserFilenameByDefaultFilename($defaultScript); } $this->RegisterScriptListByFilename($scriptList); }