public function doUninstallAction($params) { $result = false; if (strlen($params['name'])) { // Removes the new style application if (is_dir($this->container->getHome() . 'domain/' . basename($params['name']) . '-panel')) { if (\Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'domain/' . basename($params['name']) . '-panel')) { $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to remove ' . $this->container->getHome() . 'domain/' . basename($params['name']) . '-panel', \Innomatic\Logging\Logger::ERROR); } } // Removes the old style application if (file_exists($this->container->getHome() . 'domain/' . basename($params['name']) . '.php')) { if (@unlink($this->container->getHome() . 'domain/' . basename($params['name']) . '.php')) { $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to remove ' . $this->container->getHome() . 'domain/' . basename($params['name']), \Innomatic\Logging\Logger::ERROR); } } } if (!isset($params['icon'])) { $params['icon'] = ''; } if (strlen($params['icon'])) { if (@unlink($this->container->getHome() . 'domain/' . basename($params['icon']))) { $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to remove ' . $this->container->getHome() . 'domain/' . basename($params['icon']), \Innomatic\Logging\Logger::ERROR); } } return $result; }
public function doUpdateAction($params) { if (strlen($params['name'])) { if (is_dir($this->container->getHome() . 'shared/' . basename($params['name']))) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'shared/' . basename($params['name'])); $result = true; } else { if (@unlink($this->container->getHome() . 'shared/' . basename($params['name']))) { $result = true; } } $file = $this->basedir . '/shared/' . $params['name']; if (is_dir($file)) { if (\Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($file . '/', $this->container->getHome() . 'shared/' . basename($file) . '/')) { $result = true; } } else { if (@copy($file, $this->container->getHome() . 'shared/' . basename($file))) { @chmod($this->container->getHome() . 'shared/' . basename($file), 0644); $result = true; } } } else { $this->mLog->logEvent('innomatic.sharedcomponent.sharedcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty shared file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
public function doUninstallAction($params) { $result = false; if (strlen($params['name'])) { if (\Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/temp/' . $params['name'])) { $result = true; } else { $this->mLog->logEvent('innomatic.tempdircomponent.tempdircomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to remove temporary directory', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('innomatic.tempdircomponent.tempdircomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty temporary directory file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
public function doUninstallAction($params) { $result = false; if (strlen($params['file'])) { if (is_dir(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file'])) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file']); $result = true; } else { $result = true; } } else { $this->mLog->logEvent('innomatic.webappconfiguration.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
private function eraseDirContent($dir, $preserveFile = '') { $dirstream = @opendir($dir); if ($dirstream) { while (false !== ($filename = readdir($dirstream))) { if ($filename != '.' && $filename != '..' && $filename != $preserveFile) { if (is_file($dir . '/' . $filename)) { unlink($dir . '/' . $filename); } if (is_dir($dir . '/' . $filename)) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($dir . '/' . $filename); } } } closedir($dirstream); } return true; }
public static function cleanup($eventData = '', $log = '') { $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($container->getHome() . 'core/temp/innomatic/'); \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($container->getHome() . 'setup'); //@unlink($container->getHome().'core/conf/kickstart.ini'); //@unlink($container->getHome().'core/bin/kickstart.php'); @touch($container->getHome() . 'core/temp/setup_cleanedup', time()); if (file_exists($container->getHome() . 'core/temp/setup_cleaningup')) { @unlink($container->getHome() . 'core/temp/setup_cleaningup'); } @touch($container->getHome() . 'core/temp/setup_setupfinished', time()); return true; }
/** * Completely erases a webapp folder and its content. * * @param string $webappName * @return bool */ public static function eraseWebApp($webappName) { $home = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getHome(); // Cannot remove innomatic webapp. if ($webappName == 'innomatic') { return false; } // Checks that the webapp name doesn't contain a malicious path. if (\Innomatic\Security\SecurityManager::isAboveBasePath($home . $webappName, $home)) { return false; } // Removes the webapp. \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($home . $webappName); }
public function doUpdateAction($params) { $result = false; $name = $params['name']; if (!isset($params['icon'])) { $params['icon'] = ''; } if (!isset($params['catalog'])) { $params['catalog'] = ''; } if (!isset($params['themeicon'])) { $params['themeicon'] = ''; } if (!isset($params['themeicontype'])) { $params['themeicontype'] = ''; } if (strlen($params['name'])) { if (isset($params['icon']) and strlen($params['icon'])) { $params['icon'] = $this->basedir . '/root/' . $params['icon']; if (@copy($params['icon'], $this->container->getHome() . 'root/' . basename($params['icon']))) { @chmod($this->container->getHome() . 'root/' . basename($params['icon']), 0644); $result = true; } else { $this->mLog->logEvent('innomatic.rootpanelcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy root application icon ' . $params['icon'] . ' to destination ' . $this->container->getHome() . 'root/' . basename($params['icon']), \Innomatic\Logging\Logger::ERROR); } } $params['name'] = $this->basedir . '/root/' . $params['name']; $result = false; if (file_exists($this->container->getHome() . 'root/' . basename($params['name']) . '.php')) { @unlink($this->container->getHome() . 'root/' . basename($params['name']) . '.php'); } if (is_dir($this->container->getHome() . 'root/' . basename($params['name']) . '-panel')) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'root/' . basename($params['name']) . '-panel'); } if (is_dir($params['name'] . '-panel')) { if (\Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($params['name'] . '-panel/', $this->container->getHome() . 'root/' . basename($params['name']) . '-panel/')) { $result = true; } } else { if (file_exists($params['name']) . '.php') { $result = @copy($params['name'] . '.php', $this->container->getHome() . 'root/' . basename($params['name']) . '.php'); if ($result) { @chmod($this->container->getHome() . 'root/' . basename($params['name']) . '.php', 0644); } } } if ($result) { if (!isset($params['category'])) { $params['category'] = ''; } $group_query = $this->rootda->execute('SELECT * ' . 'FROM root_panels_groups ' . 'WHERE name = ' . $this->rootda->formatText($params['category'])); if ($group_query->getNumberRows()) { $group_id = $group_query->getFields('id'); } else { $group_id = ''; } $result = $this->rootda->execute('UPDATE root_panels SET iconfile=' . $this->rootda->formatText(basename($params['icon'])) . ',' . 'catalog=' . $this->rootda->formatText($params['catalog']) . ',' . 'themeicon=' . $this->rootda->formatText($params['themeicon']) . ',' . 'themeicontype=' . $this->rootda->formatText($params['themeicontype']) . ($group_id ? ',groupid=' . $group_id : '') . ' WHERE name=' . $this->rootda->formatText($name)); if (!$result) { $this->mLog->logEvent('innomatic.rootpanelcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $name . ': Unable to update root application in root_panels table', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('innomatic.rootpanelcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $name . ': Unable to copy root application file ' . $name . ' to destination ' . $this->container->getHome() . 'root/' . basename($name), \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('innomatic.rootpanelcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $name . ': Empty application file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
public function remove() { $hook = new \Innomatic\Process\Hook($this->rootDA, 'innomatic', 'domain.user.remove'); if ($hook->callHooks('calltime', $this, array('domainserial' => $this->domainserial, 'userid' => $this->userid)) == \Innomatic\Process\Hook::RESULT_OK) { if ($this->userid != 0) { $result = $this->domainDA->execute('DELETE FROM domain_users WHERE id=' . (int) $this->userid); // Remove user dir $domain_query = $this->rootDA->execute('SELECT domainid FROM domains WHERE id=' . (int) $this->domainserial); if ($this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/' . $this->username != $this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/') { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/' . $this->username, 0755); } // Remove cached items $cache_gc = new \Innomatic\Datatransfer\Cache\CacheGarbageCollector(); $cache_gc->removeUserItems((int) $this->userid); //$this->htp->remuser( $this->username ); if ($hook->callHooks('userremoved', $this, array('domainserial' => $this->domainserial, 'userid' => $this->userid)) != \Innomatic\Process\Hook::RESULT_OK) { $result = false; } $this->userid = 0; $this->userExists = false; } } return $result; }
/** * Undeploys a Module in the Module server. * * @param string $location Module name. * @return boolean * @since 5.1 */ public function undeploy($location) { // Checks if the specified Module exists. $context = \Innomatic\Module\Server\ModuleServerContext::instance('\\Innomatic\\Module\\Server\\ModuleServerContext'); if (!is_dir($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $location)) { throw new \Innomatic\Module\ModuleException('No such Module'); } // Executes Module undeploy hooked actions. $auth = \Innomatic\Module\Server\ModuleServerAuthenticator::instance('ModuleServerAuthenticator'); $module = \Innomatic\Module\ModuleFactory::getModule(new ModuleLocator('module://*****:*****@/' . $location)); $module->undeploy(); // Removes Module. \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $location); // Logs undeployment. if ($context->getConfig()->getKey('log_deployer_events') == 1 or $context->getConfig()->useDefaults()) { $logger = new \Innomatic\Module\Server\ModuleServerLogger($context->getHome() . 'core/log/module-deployer.log'); $logger->logEvent($location . ' undeployed'); } return true; }
/** * Removes webapp cache directory. */ public function refresh() { if (is_dir($this->getVarDir() . 'cache/')) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->getVarDir()); } }
public function remove() { $result = false; $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'domain.remove'); if ($hook->callHooks('calltime', $this, '') == \Innomatic\Process\Hook::RESULT_OK) { $query = $this->rootda->execute('SELECT * FROM domains WHERE id=' . (int) $this->domainserial); $data = $query->getFields(); // Set the current domain object so that any component relying on // the InnomaticContainer current domain does not fail $this->container->setCurrentDomain($this); // Removes domain users. // They must be removed before disabling applications // and dropping the database. $this->removeAllUsers(); // Disables all applications. $this->disableAllApplications($this->domainserial); if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) { $args['dbname'] = $data['domaindaname']; $args['dbhost'] = $data['dataaccesshost']; $args['dbport'] = $data['dataaccessport']; $args['dbuser'] = $data['dataaccessuser']; $args['dbpass'] = $data['domaindapass']; $args['dbtype'] = $data['dataaccesstype']; $args['dblog'] = $this->container->getHome() . 'core/domains/' . $data['domainid'] . '/log/dataaccess.log'; $this->dataAccess->close(); $this->dataAccess->dropDB($args); } // Removes cached items. $cache_gc = new \Innomatic\Datatransfer\Cache\CacheGarbageCollector(); $cache_gc->removeDomainItems((int) $data['id']); // Removes domain from root database. $this->rootda->execute('DELETE FROM domains WHERE id=' . (int) $data['id']); $this->rootda->execute('DELETE FROM applications_options_disabled WHERE domainid=' . $this->domainserial); $log = $this->container->getLogger(); $log->logEvent($data['domainid'], 'Removed domain ' . $data['domainid'], \Innomatic\Logging\Logger::NOTICE); if (!empty($data['domainid']) and !in_array($data['domainid'], $this->reservedNames)) { if (!\Innomatic\Security\SecurityManager::isAboveBasePath($this->container->getHome() . 'core/domains/' . $data['domainid'], $this->container->getHome() . 'core/domains/')) { // Removes domain directory inside Innomatic webapp \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/domains/' . $data['domainid']); } // Removes domain webapp \Innomatic\Webapp\WebAppContainer::eraseWebApp($data['domainid']); } if ($hook->callHooks('domainremoved', $this, '') == \Innomatic\Process\Hook::RESULT_OK) { $result = true; } // Tells the security manager that the domain has been removed. if ($this->container->getConfig()->Value('SecurityAlertOnDomainOperation') == '1') { $innomatic_security = new \Innomatic\Security\SecurityManager(); $innomatic_security->sendAlert('Domain ' . $data['domainid'] . ' has been removed'); unset($innomatic_security); } } return $result; }
public function doUpdateAction($params) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'shared/help/' . basename($params['file'])); return $this->doInstallAction($params); }
public function doUpdateAction($params) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/locale/catalogs/' . basename($params['name'])); return $this->doInstallAction($params); }
public function doUpdateAction($params) { // Checks component name. if (!strlen($params['name'])) { $this->mLog->logEvent('WebappskeletonComponent::doUdpateAction', 'Empty webapp skeleton name in application ' . $this->appname, \Innomatic\Logging\Logger::ERROR); return false; } // Source folder. $skeleton_source = $this->basedir . '/core/conf/skel/webapps/' . basename($params['name']) . '-skel/'; // Checks if the skeleton directory exists in application archive. if (!is_dir($skeleton_source)) { $this->mLog->logEvent('WebappskeletonComponent::doUdpateAction', 'Missing webapp skeleton folder (' . basename($params['name']) . '-skel) in application ' . $this->appname, \Innomatic\Logging\Logger::ERROR); return false; } // Destination folder. $skeleton_destination = $this->container->getHome() . 'core/conf/skel/webapps/' . basename($params['name']) . '-skel/'; // Removes previous skeleton directory. \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($skeleton_destination); // Copies the skeleton folder to the destination. $result = \Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($skeleton_source, $skeleton_destination); if (!$result) { $this->mLog->logEvent('WebappskeletonComponent::doUdpateAction', 'Unable to copy webapp skeleton source folder (' . $skeleton_source . ') to its destination (' . $skeleton_destination . ') in application ' . $this->appname, \Innomatic\Logging\Logger::ERROR); return false; } // Checks if the webapp skeleton row exists in webapps_skeletons table. // If it doesn't exists it could means that Innomatic was unable to insert it // in a previous application installation. In this case, it tries to reinsert // a new row. $check_query = $this->rootda->execute('SELECT name FROM webapps_skeletons WHERE name=' . $this->rootda->formatText($params['name'])); if ($check_query->getNumberRows()) { // Updates the skeleton row in the webapps_skeletons table. $result = $this->rootda->execute('UPDATE webapps_skeletons SET catalog=' . $this->rootda->formatText($params['catalog']) . ' ' . 'WHERE name=' . $this->rootda->formatText($params['name'])); if (!$result) { $this->mLog->logEvent('WebappskeletonComponent::doUdpateAction', 'Unable to update webapp skeleton row (' . basename($params['name']) . ') in webapps_skeletons table in application ' . $this->appname, \Innomatic\Logging\Logger::ERROR); return false; } } else { // Adds the skeleton to the webapps_skeletons table. $result = $this->rootda->execute('INSERT INTO webapps_skeletons VALUES (' . $this->rootda->formatText($params['name']) . ',' . $this->rootda->formatText($params['catalog']) . ')'); if (!$result) { $this->mLog->logEvent('WebappskeletonComponent::doUdpateAction', 'Unable to insert webapp skeleton ' . basename($params['name']) . ' to webapps_skeletons table in application ' . $this->appname, \Innomatic\Logging\Logger::ERROR); return false; } } return true; }
public function uninstall() { $result = false; if ($this->serial) { // Checks if the application exists in applications table // $modquery = $this->rootda->execute('SELECT * FROM applications WHERE id=' . (int) $this->serial); if ($modquery->getNumberRows() == 1) { $appdata = $modquery->getFields(); // Checks if the application is Innomatic itself // if ($appdata['appid'] != 'innomatic') { // Checks if the structure file still exists // if (file_exists($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml')) { $this->appname = $appdata['appid']; // Checks if there are depengind applications // $appdeps = new ApplicationDependencies(); $pendingdeps = $appdeps->CheckDependingApplications($appdata['appid']); // If dependencies are ok, go on // if ($pendingdeps == false) { if ($appdata['onlyextension'] != $this->rootda->fmttrue) { $this->disableFromAllDomains($appdata['appid']); } $this->HandleStructure($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml', Application::INSTALL_MODE_UNINSTALL, $this->container->getHome() . 'core/temp/appinst/'); // Removes application archive and directory // if (file_exists($this->container->getHome() . 'core/applications/' . $appdata['appfile'])) { @unlink($this->container->getHome() . 'core/applications/' . $appdata['appfile']); } \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/applications/' . $appdata['appid']); // Application rows in applications table // $this->rootda->execute('DELETE FROM applications WHERE id=' . (int) $this->serial); // Remove cached items // $cacheGC = new \Innomatic\Datatransfer\Cache\CacheGarbageCollector(); $cacheGC->removeApplicationItems($appdata['appid']); // Remove pending actions \Innomatic\Scripts\PendingActionsUtils::removeByApplication($appdata['appid']); // Remove dependencies // $appdeps->removeAllDependencies($this->serial); $this->serial = 0; $result = true; if ($this->container->getConfig()->Value('SecurityAlertOnApplicationOperation') == '1') { $innomaticSecurity = new \Innomatic\Security\SecurityManager(); $innomaticSecurity->SendAlert('Application ' . $appdata['appid'] . ' has been removed'); unset($innomaticSecurity); } } else { $this->unmetdeps = $pendingdeps; } if ($result == true) { $log = $this->container->getLogger(); $log->logEvent('Innomatic', 'Uninstalled application ' . $this->appname, \Innomatic\Logging\Logger::NOTICE); } } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.uninstall', 'Structure file ' . $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml' . ' for application ' . $appdata['appid'] . ' was not found', \Innomatic\Logging\Logger::ERROR); } } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.uninstall', 'Cannot uninstall Innomatic', \Innomatic\Logging\Logger::ERROR); } } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.uninstall', 'A application with serial ' . $this->serial . ' was not found in applications table', \Innomatic\Logging\Logger::ERROR); } $modquery->free(); } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.uninstall', 'Empty application serial', \Innomatic\Logging\Logger::ERROR); } return $result; }
public function doDisableDomainAction($domainid, $params) { $domainQuery = $this->rootda->execute("SELECT domainid FROM domains WHERE id={$domainid}"); if (!$domainQuery->getNumberRows()) { return false; } $domain = $domainQuery->getFields('domainid'); $assetDestFolder = RootContainer::instance('\\Innomatic\\Core\\RootContainer')->getHome() . $domain . '/assets/' . basename($params['asset']) . '/'; if (is_dir($assetDestFolder)) { return DirectoryUtils::unlinkTree($assetDestFolder); } else { return false; } }