public function cleanCache()
 {
     $gc = new \Innomatic\Datatransfer\Cache\CacheGarbageCollector();
     return $gc->emptyCache();
 }
 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 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;
 }
Exemple #4
0
 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;
 }