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 doInstallAction($params) { // Checks if the name is valid. if (!strlen($params['name'])) { $this->mLog->logEvent('ScriptComponent::doInstallAction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty script file name', \Innomatic\Logging\Logger::ERROR); return false; } // Checks if the script file exists in application archive. if (!file_exists($this->basedir . '/core/scripts/' . $params['name'])) { $this->mLog->logEvent('ScriptComponent::doInstallAction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Missing script file', \Innomatic\Logging\Logger::ERROR); return false; } // Cheks that the script file name does not contain malicious code. if (\Innomatic\Security\SecurityManager::isAboveBasePath($this->container->getHome() . 'core/scripts/' . $params['name'], $this->container->getHome() . 'core/scripts/')) { $this->mLog->logEvent('ScriptComponent::doInstallAction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Malicious script file name', \Innomatic\Logging\Logger::ERROR); return false; } // Checks if the script file name contains a directory. $dirname = dirname($params['name']); if ($dirname != '.') { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/scripts/' . $params['name'], 0755); } // Copies the script file. if (!copy($this->basedir . '/core/scripts/' . $params['name'], $this->container->getHome() . 'core/scripts/' . $params['name'])) { $this->mLog->logEvent('ScriptComponent::doInstallAction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy script file', \Innomatic\Logging\Logger::ERROR); return false; } // Updates file permissions. chmod($this->container->getHome() . 'core/scripts/' . $params['name'], 0644); return true; }
public function __construct($rootda, $domainda, $appname, $name, $basedir) { parent::__construct($rootda, $domainda, $appname, $name, $basedir); // Checks if the classes folder exists if (!is_dir($this->container->getHome() . 'core/modules/')) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/modules/', 0755); clearstatcache(); } }
public function doInstallAction($args) { $args['file'] = $this->basedir . '/core/classes/shared/dashboard/' . basename($args['file']); // Check if the shared dashboard widgets directory exists if (!is_dir($this->container->getHome() . 'core/classes/shared/dashboard/')) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/classes/shared/dashboard/', 0755); } @copy($args['file'], $this->container->getHome() . 'core/classes/shared/dashboard/' . basename($args['file'])); @chmod($this->container->getHome() . 'core/classes/shared/dashboard/' . basename($args['file']), 0644); return true; }
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 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 store($content, $validator = '') { $result = false; $this->mResult = CachedItem::ITEM_NOT_STORED; if (!$this->mrRootDb->isConnected()) { $this->mResult = CachedItem::ITEM_NOT_FOUND; return false; } $goon = false; $sem = new \Innomatic\Process\Semaphore('cache', $this->mItemFile); $sem->waitGreen(); $sem->setRed(); if (strlen($this->mItemFile) and file_exists($this->mItemFile)) { if ($fh = @fopen($this->mItemFile, 'w')) { if (@fwrite($fh, $content)) { $name = $this->mItemFile; $goon = true; } fclose($fh); } } else { $name = $this->cachePath . date('Ymd') . '_cacheditem_' . rand(); if (!file_exists($this->cachePath)) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->cachePath, 0755); } if ($fh = @fopen($name, 'w')) { if (@fwrite($fh, $content)) { $goon = true; } @fclose($fh); } } if ($goon) { $item_query = $this->mrRootDb->execute('SELECT itemid FROM cache_items WHERE itemid=' . $this->mrRootDb->formatText($this->mItemId) . ' AND application=' . $this->mrRootDb->formatText($this->mApplication) . ($this->mDomainId ? ' AND domainid=' . $this->mDomainId : '') . ($this->mUserId ? ' AND userid=' . $this->mUserId : '')); if ($item_query->getNumberRows()) { if ($this->mrRootDb->execute('UPDATE cache_items SET validator=' . $this->mrRootDb->formatText($validator) . ',itemfile=' . $this->mrRootDb->formatText(basename($name)) . ',domainid=' . $this->mDomainId . ',userid=' . $this->mUserId . ' WHERE itemid=' . $this->mrRootDb->formatText($this->mItemId) . ' AND application=' . $this->mrRootDb->formatText($this->mApplication))) { $result = true; } } else { if ($this->mrRootDb->execute('INSERT INTO cache_items VALUES (' . $this->mrRootDb->formatText($this->mApplication) . ',' . $this->mrRootDb->formatText($this->mItemId) . ',' . $this->mrRootDb->formatText(basename($name)) . ',' . $this->mrRootDb->formatText($validator) . ',' . $this->mDomainId . ',' . $this->mUserId . ')')) { $result = true; } } if ($result) { $this->mItemFile = $name; $this->mValidator = $validator; $this->mResult = CachedItem::ITEM_STORED; } } // The semaphore gets unlocked anyway, even if the operation has failed. $sem->setGreen(); 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 function doUpdateDomainAction($domainid, $params) { $domainQuery = $this->rootda->execute("SELECT domainid FROM domains WHERE id={$domainid}"); if (!$domainQuery->getNumberRows()) { return false; } $domain = $domainQuery->getFields('domainid'); $fileDestName = RootContainer::instance('\\Innomatic\\Core\\RootContainer')->getHome() . $domain . '/core/classes/' . $params['file']; if (!file_exists(RootContainer::instance('\\Innomatic\\Core\\RootContainer')->getHome() . $domain . '/core/classes/' . dirname($params['file']))) { \Innomatic\Io\Filesystem\DirectoryUtils::mkTree(RootContainer::instance('\\Innomatic\\Core\\RootContainer')->getHome() . $domain . '/core/classes/' . dirname($params['file']) . '/', 0755); } if (!copy(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file'], $fileDestName)) { return false; } 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; }
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) { $result = false; if (strlen($params['file'])) { $params['file'] = $this->basedir . '/core/conf/themes/' . basename($params['file']); // Creates themes configuration folder if it doesn't exists if (!is_dir($this->container->getHome() . 'core/conf/themes/')) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/conf/themes/', 0755); } if (@copy($params['file'], $this->container->getHome() . 'core/conf/themes/' . basename($params['file']))) { @chmod($this->container->getHome() . 'core/conf/themes/' . basename($params['file']), 0644); $wui_component = new \Innomatic\Wui\Theme\WuiStyle($this->rootda, $params['name']); $params['file'] = basename($params['file']); if ($wui_component->Update($params)) { $style_components = $wui_component->getStyle(); if (!file_exists($this->container->getHome() . 'shared/styles')) { @mkdir($this->container->getHome() . 'shared/styles', 0755); } if (!file_exists($this->container->getHome() . 'shared/styles/' . $params['name'])) { @mkdir($this->container->getHome() . 'shared/styles/' . $params['name'], 0755); } while (list(, $file) = each($style_components)) { if (strlen($file['value'])) { @copy($this->basedir . '/shared/styles/' . $params['name'] . '/' . $file['value'], $this->container->getHome() . 'shared/styles/' . $params['name'] . '/' . $file['value']); } } $result = true; } else { $this->mLog->logEvent('innomatic.wuistylecomponent.wuistyle.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to update component', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('innomatic.wuistylecomponent.wuistyle.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy wui component file (' . $params['file'] . ') to its destination (' . $this->container->getHome() . 'core/conf/themes/' . basename($params['file']) . ')', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('innomatic.wuistylecomponent.wuistyle.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty component file name', \Innomatic\Logging\Logger::ERROR); } 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; }
/** * 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 doUpdateAction($params) { $result = false; if (strlen($params['file'])) { $params['file'] = $this->basedir . '/core/conf/themes/' . basename($params['file']); // Creates themes configuration folder if it doesn't exists if (!is_dir($this->container->getHome() . 'core/conf/themes/')) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/conf/themes/', 0755); } if (@copy($params['file'], $this->container->getHome() . 'core/conf/themes/' . basename($params['file']))) { @chmod($this->container->getHome() . 'core/conf/themes/' . basename($params['file']), 0644); $params['file'] = basename($params['file']); $check_query = $this->rootda->execute('SELECT name FROM wui_themes WHERE name=' . $this->rootda->formatText($params['name'])); if ($check_query->getNumberRows()) { $result = $this->rootda->execute('UPDATE wui_themes SET file=' . $this->rootda->formatText($params['file']) . ',catalog=' . $this->rootda->formatText($params['catalog']) . ' WHERE name=' . $this->rootda->formatText($params['name'])); } else { $result = $this->rootda->execute('INSERT INTO wui_themes VALUES (' . $this->rootda->getNextSequenceValue('wui_themes_id_seq') . ',' . $this->rootda->formatText($params['name']) . ',' . $this->rootda->formatText($params['file']) . ',' . $this->rootda->formatText($params['catalog']) . ')'); } if (!$result) { $this->mLog->logEvent('shared.components.wuithemecomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to update component', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('shared.components.wuithemecomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy wui component file (' . $params['file'] . ') to its destination (' . $this->container->getHome() . 'core/conf/themes/' . basename($params['file']) . ')', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLog->logEvent('shared.components.wuithemecomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty component file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
/** * Saving the media in storage * @param string $mediaTempPath Url temporary medias * @param boolean $deleteSource Delete the temporary file if requireds * @return object_media returns the object Media createds */ public function setMedia($mediaTempPath, $deleteSource = true) { // The temporary source media must exists if (!file_exists($mediaTempPath)) { return $this; } // If no name has been previously provided, guess it from // temporary media file name if (!strlen($this->name)) { $this->name = basename($mediaTempPath); } // Start Manage creation name of the images $mediaQuery = $this->getMediaForBlock(); $suffix = $mediaQuery->getNumberRows(); if ($suffix > 0) { while (!$mediaQuery->eof) { $last_media_name = $mediaQuery->getFields('name'); $mediaQuery->moveNext(); } $string_explode = explode('-', explode('.', $last_media_name)[0]); $suffix = array_pop($string_explode) + 1; } $pos = strrpos($this->name, "."); if ($pos === false) { // not found... $extension = ""; } else { $extension = substr($this->name, $pos + 1); } $current_language = \Innomedia\Locale\LocaleWebApp::getCurrentLanguage('backend'); $new_name = str_replace("/", "", $this->pageName); $new_name .= "-" . $this->pageId; $new_name .= "-" . str_replace("/", "", $this->blockName); $new_name .= "-" . $this->blockCounter; $new_name .= "-" . $this->type; $new_name .= "-" . str_replace('__', '', $current_language); $new_name .= "-" . $suffix . "." . $extension; $this->name = $new_name; // END Manage creation name of the images // Build the destination path in the storage $destPath = $this->getPath(true); // Check if the destination directory exists $dirName = dirname($destPath) . '/'; if (!file_exists($dirName)) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($dirName, 0755); } // Copy the file inside the media storage copy($mediaTempPath, $destPath); // Delete the temporary file if required if ($deleteSource == true) { unlink($mediaTempPath); } return $this; }
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) { // 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; }
protected function getRelativePath(WebAppRequest $request) { $result = $request->getPathInfo(); return \Innomatic\Io\Filesystem\DirectoryUtils::normalize(strlen($result) ? $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; }
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 doUpdateAction($params) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/locale/catalogs/' . basename($params['name'])); return $this->doInstallAction($params); }
/** * Used only when the component is a domain override. * * @param unknown_type $domainid * @param unknown_type $params * @return bool */ public function doEnableDomainAction($domainid, $params) { if (!strlen($params['name'])) { return false; } if (!isset($params['override']) and $params['override'] = self::OVERRIDE_DOMAIN) { return true; } $domain_query = $this->rootda->execute('SELECT domainid FROM domains WHERE id=' . $domainid); if ($domain_query == false or $domain_query->getNumberRows() == 0) { return false; } $domain_id = $domain_query->getFields('domainid'); // Checks if the classes override directory exists if (!is_dir($this->container->getHome() . 'core/domains/' . $domain_id . '/overrides/classes/')) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/domains/' . $domain_id . '/overrides/classes/', 0755); clearstatcache(); } if (!file_exists($this->container->getHome() . 'core/domains/' . $domain_id . '/overrides/classes/' . dirname($params['name']))) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/domains/' . $domain_id . '/overrides/classes/' . dirname($params['name']) . '/', 0755); } \Innomatic\Core\RootContainer::clearClassesCache(); return copy($this->container->getHome() . 'core/applications/' . $this->appname . '/overrides/classes/' . $params['name'], $this->container->getHome() . 'core/domains/' . $domain_id . '/overrides/classes/' . $params['name']); }
/** * Overwrites webapp skeleton with a new one. * The previous skeleton is not deleted, it is only overwritten. * * @param string $webappName * @param string $skeletonName * @return bool */ public static function applyNewSkeleton($webappName, $skeletonName) { $home = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getHome(); // Checks that the webapp name doesn't contain a malicious path. if (\Innomatic\Security\SecurityManager::isAboveBasePath($home . $webappName, $home)) { return false; } // Strips any path info from the skeleton name. $skeletonName = basename($skeletonName); // Checks if the given skeleton exits, otherwise uses default one. if (!is_dir($home . 'innomatic/core/conf/skel/webapps/' . $skeletonName . '-skel/')) { return false; } // Copies the skeleton to the webapp directory, overwriting previos skeleton. return \Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($home . 'innomatic/core/conf/skel/webapps/' . $skeletonName . '-skel/', $home . $webappName . '/'); }
/** * Builds the webapp request */ private function parseRequest() { // URL path part //TODO ipotizza che ci sia il receiver nella URL $url_path = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')); $this->request->setUrlPath($url_path); // Remote address $this->request->setRemoteAddr($_SERVER['REMOTE_ADDR']); // Server name list($servername) = explode(':', $_SERVER['HTTP_HOST']); $this->request->setServerName($servername); // Server port $this->request->setServerPort($_SERVER['SERVER_PORT']); // Request URI if ($this->request->isUrlRewriteOn()) { $path_info = substr($_SERVER['REQUEST_URI'], strlen($url_path)); } else { $path_info = $_SERVER['PATH_INFO']; } if (strpos($path_info, '?')) { $path_info = substr($path_info, 0, strpos($path_info, '?')); } $requestURI = $url_path . $path_info; $normalizedURI = \Innomatic\Io\Filesystem\DirectoryUtils::normalize($requestURI); if ($url_path != '/' && $url_path == $normalizedURI) { $normalizedURI .= '/'; } $this->request->setRequestURI($normalizedURI); // Request method $this->request->setMethod($_SERVER['REQUEST_METHOD']); // Request protocol $this->request->setProtocol($_SERVER['SERVER_PROTOCOL']); $this->response->setProtocol($_SERVER['SERVER_PROTOCOL']); // Query string if (strlen($_SERVER['QUERY_STRING']) > 0) { $this->request->setQueryString($_SERVER['QUERY_STRING']); } // Scheme and secure flag if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $this->request->setScheme('https'); $this->request->setSecure(true); } else { $this->request->setScheme('http'); } // POST, GET and FILES parameters $parameters = array(); parse_str($this->request->getQueryString(), $results); foreach ($results as $name => $values) { settype($values, 'array'); $parameters[$name] = array_values($values); } foreach ($_POST as $name => $values) { settype($values, 'array'); $parameters[$name] = array_values($values); } foreach ($_FILES as $name => $values) { settype($values, 'array'); $parameters[$name] = array_values($values); } $this->request->setParameters($parameters); // Input $this->request->setInput($_POST); // Accepted languages $value = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'en_US'; $locales = array(); $value = str_replace(array(' ', "\t"), '', $value); $entries = explode(',', $value); foreach ($entries as $entry) { // extract the quality factor $quality = 1.0; if (($semi = strpos($entry, ';q=')) !== false) { $quality = (double) substr($entry, $semi + 3); $entry = substr($entry, 0, $semi); } $localeParts = explode('-', $entry); $language = $locale = $localeParts[0]; $country = ''; $varient = ''; if (count($localeParts) > 1) { $country = $localeParts[1]; $locale .= '_' . strtoupper($country); if (count($localeParts) > 2) { $variant = $localeParts[2]; $locale .= '_' . $variant; } } $key = -$quality; if (empty($locales["{$key}"])) { $locales["{$key}"] = array(); } $locales["{$key}"][] = $locale; } ksort($locales); foreach ($locales as $localeSet) { foreach ($localeSet as $locale) { $this->request->addLocale($locale); } } }
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; } }