public function testZipDirectory() { $objFileSystem = new class_filesystem(); echo "\t creating test structure\n"; $objFileSystem->folderCreate("/files/cache/ziptest"); $this->assertFileExists(_realpath_ . "/files/cache/ziptest", __FILE__ . " checkFileNotExists"); $objFileSystem->folderCreate("/files/cache/ziptest/subdir"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/licence_lgpl1.txt"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/licence_lgpl2.txt"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/subdir/licence_lgpl.txt"); echo "\ttesting class_zip...\n"; $objZip = new class_zip(); echo "\topening test.zip\n"; $this->assertTrue($objZip->openArchiveForWriting("/files/cache/test.zip"), __FILE__ . " openArchive"); $this->assertTrue($objZip->addFolder("/files/cache/ziptest"), __FILE__ . " addFolder"); $this->assertTrue($objZip->closeArchive(), __FILE__ . " closeArchive"); $this->assertFileExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileExists"); echo "\textracting files\n"; $objFileSystem->folderCreate("/files/cache/zipextract"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileExists"); $objZip = new class_zip(); $this->assertTrue($objZip->extractArchive("/files/cache/test.zip", "/files/cache/zipextract"), __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/licence_lgpl1.txt", __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/licence_lgpl2.txt", __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/subdir/licence_lgpl.txt", __FILE__ . " extractArchive"); echo "\tremoving testfile\n"; $this->assertTrue($objFileSystem->fileDelete("/files/cache/test.zip"), __FILE__ . " deleteFile"); $this->assertFileNotExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileNotExists"); $objFileSystem->folderDeleteRecursive("/files/cache/ziptest"); $this->assertFileNotExists(_realpath_ . "/files/cache/ziptest", __FILE__ . " checkFileNotExists"); $objFileSystem->folderDeleteRecursive("/files/cache/zipextract"); $this->assertFileNotExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileNotExists"); }
public function testFileSync() { echo "test mediamanager...\n"; if (class_module_system_module::getModuleByName("samplecontent") == null || !is_file(_realpath_ . "/files/images/samples/IMG_3000.JPG")) { return; } $objFilesystem = new class_filesystem(); $objFilesystem->folderCreate(_filespath_ . "/images/autotest"); $objFilesystem->fileCopy(_filespath_ . "/images/samples/IMG_3000.JPG", _filespath_ . "/images/autotest/IMG_3000.jpg"); $objFilesystem->fileCopy(_filespath_ . "/images/samples/IMG_3000.JPG", _filespath_ . "/images/autotest/IMG_3000.png"); $objFilesystem->fileCopy(_filespath_ . "/images/samples/IMG_3000.JPG", _filespath_ . "/images/autotest/PA021805.JPG"); $objFilesystem->fileCopy(_filespath_ . "/images/samples/IMG_3000.JPG", _filespath_ . "/images/autotest/test.txt"); $objRepo = new class_module_mediamanager_repo(); $objRepo->setStrPath(_filespath_ . "/images/autotest"); $objRepo->setStrTitle("autotest repo"); $objRepo->setStrViewFilter(".jpg,.png"); $objRepo->updateObjectToDb(); $objRepo->syncRepo(); $arrFiles = class_module_mediamanager_file::loadFilesDB($objRepo->getSystemid()); $this->assertEquals(3, count($arrFiles)); foreach ($arrFiles as $objOneFile) { $objOneFile->deleteObjectFromDatabase(); } $objRepo->deleteObjectFromDatabase(); $arrFiles = $objFilesystem->getFilelist(_filespath_ . "/images/autotest"); $this->assertEquals(1, count($arrFiles)); $this->assertEquals("test.txt", array_values($arrFiles)[0]); }
private function extractBrowscap() { $strReturn = ""; if (!is_file(_realpath_ . _projectpath_ . "/temp/browscap.cache.php")) { $objZip = new class_gzip(); $objFile = new class_filesystem(); $objFile->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_stats") . "/module_stats/installer/browscap.cache.php.gz", _projectpath_ . "/temp/browscap.cache.php.gz"); if (is_file(_realpath_ . _projectpath_ . "/temp/browscap.cache.php.gz")) { $objZip->decompressFile(_projectpath_ . "/temp/browscap.cache.php.gz"); $objFile->fileDelete(_projectpath_ . "/temp/browscap.cache.php.gz"); touch(_realpath_ . _projectpath_ . "/temp/browscap.ini"); } else { $strReturn .= "Failed to copy the browscap file to the project folder\n"; } } else { $strReturn .= "Browscap cache file already existing\n"; } return $strReturn; }
private function update_465_47() { $strReturn = "Updating 4.6.5 to 4.7...\n"; $strReturn .= "Patching bootstrap.php < 4.7\n"; if (is_file(_realpath_ . "/core/bootstrap.php")) { $objFileystem = new class_filesystem(); if (!$objFileystem->isWritable("/core/bootstrap.php")) { $strReturn .= "Error! /core/bootstrap.php is not writable. Please set up write permissions for the update-procedure.\nAborting update."; return $strReturn; } $objFileystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/installer/bootstrap.php_47", "/core/bootstrap.php", true); } $strReturn .= "Updating module-versions...\n"; $this->updateModuleVersion($this->objMetadata->getStrTitle(), "4.7"); return $strReturn; }
/** * Imports the given db-dump file to the database. The filename ist relative to _realpath_ * * @param string $strFilename * * @return bool */ public function dbImport($strFilename) { $objFilesystem = new class_filesystem(); return $objFilesystem->fileCopy($strFilename, $this->strDbFile, true); }
private function update_42_43() { $strReturn = "Updating 4.2 to 4.3...\n"; $strReturn .= "Changing placeholder column data-type...\n"; $strReturn .= "Creating temp-table...\n"; $strReturn .= "Installing table page_element...\n"; $arrFields = array(); $arrFields["page_element_id"] = array("char20", false); $arrFields["page_element_ph_placeholder"] = array("text", true); $arrFields["page_element_ph_name"] = array("char254", true); $arrFields["page_element_ph_element"] = array("char254", true); $arrFields["page_element_ph_title"] = array("char254", true); $arrFields["page_element_ph_language"] = array("char20", true); if (!$this->objDB->createTable("page_element_temp", $arrFields, array("page_element_id"), array("page_element_ph_language", "page_element_ph_element"))) { $strReturn .= "An error occurred! ...\n"; } $strReturn .= "Copying table content...\n"; $strQuery = "INSERT INTO " . _dbprefix_ . "page_element_temp\n (page_element_id, page_element_ph_placeholder, page_element_ph_name, page_element_ph_element, page_element_ph_title, page_element_ph_language)\n SELECT page_element_id, page_element_ph_placeholder, page_element_ph_name, page_element_ph_element, page_element_ph_title, page_element_ph_language FROM " . _dbprefix_ . "page_element"; if (!$this->objDB->_query($strQuery)) { $strReturn .= "An error occurred! ...\n"; } $strReturn .= "Dropping old table...\n"; $strQuery = "DROP TABLE " . $this->objDB->encloseTableName(_dbprefix_ . "page_element") . ""; if (!$this->objDB->_query($strQuery)) { $strReturn .= "An error occurred! ...\n"; } $strReturn .= "Renaming new table...\n"; $strQuery = "ALTER TABLE " . $this->objDB->encloseTableName(_dbprefix_ . "page_element_temp") . " RENAME TO " . $this->objDB->encloseTableName(_dbprefix_ . "page_element") . ""; if (!$this->objDB->_query($strQuery)) { $strReturn .= "An error occurred! ...\n"; } $strReturn .= "Copying default-template, if in use. Placeholders changed in 4.3\n"; if (class_module_system_setting::getConfigValue("_packagemanager_defaulttemplate_") == "default") { $objFS = new class_filesystem(); $objFS->folderCreate("/templates/kajona42/tpl/module_pages", true); $objFS->fileCopy("/core/module_pages/installer/standard.tpl.42", "/templates/kajona42/tpl/module_pages/standard.tpl"); class_module_packagemanager_template::syncTemplatepacks(); /** @var $objOnePack class_module_packagemanager_template */ foreach (class_module_packagemanager_template::getObjectList() as $objOnePack) { if ($objOnePack->getStrName() == "kajona42") { $objOnePack->setIntRecordStatus(1); $objOnePack->updateObjectToDb(); } } $objSetting = class_module_system_setting::getConfigByName("_packagemanager_defaulttemplate_"); $objSetting->setStrValue("kajona42"); $objSetting->updateObjectToDb(); } $strReturn .= "Updating module-versions...\n"; $this->updateModuleVersion("", "4.3"); $strReturn .= "Updating element-version...\n"; $this->updateElementVersion("row", "4.3"); $this->updateElementVersion("paragraph", "4.3"); $this->updateElementVersion("image", "4.3"); return $strReturn; }