public function doInstallAction($params) { if (!strlen($params['name'])) { $this->mLog->logEvent('innomatic.catalogcomponent.catalogcomponent.doinstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty catalog name', \Innomatic\Logging\Logger::ERROR); return false; } $catalog = $this->basedir . '/core/locale/catalogs/' . $params['name']; // Check if the help directory exists and if not, create it. // if (!is_dir($this->container->getHome() . 'core/locale/catalogs/')) { $old_umask = umask(0); @mkdir($this->container->getHome() . 'core/locale/catalogs/', 0755); umask($old_umask); } return \Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($catalog . '/', $this->container->getHome() . 'core/locale/catalogs/' . basename($catalog) . '/'); }
public function doInstallAction($params) { $result = false; if (strlen($params['file'])) { $params['file'] = $this->basedir . '/shared/help/' . $params['file']; // Check if the help directory exists and if not, create it. // if (!is_dir($this->container->getHome() . 'shared/help/')) { $old_umask = umask(0); @mkdir($this->container->getHome() . 'shared/help/', 0755); umask($old_umask); } if (\Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($params['file'] . '/', $this->container->getHome() . 'shared/help/' . basename($params['file']) . '/')) { //@chmod( $this->container->getHome().'shared/help/'.basename( $params['file'] ), 0644 ); $result = true; } } else { $this->mLog->logEvent('innomatic.helpnodecomponent.helpnodecomponent.doinstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty helpnode file name', \Innomatic\Logging\Logger::ERROR); } return $result; }
public function doInstallAction($params) { $result = false; if (strlen($params['name'])) { $params['name'] = $this->basedir . '/domain/' . $params['name']; if (is_dir($params['name'] . '-panel')) { if (\Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($params['name'] . '-panel/', $this->container->getHome() . 'domain/' . basename($params['name']) . '-panel/')) { $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.doinstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy ' . $params['name'] . '-panel into destination ' . $this->container->getHome() . 'domain/' . basename($params['name']) . '-panel', \Innomatic\Logging\Logger::ERROR); } } else { if (file_exists($params['name'] . '.php')) { if (@copy($params['name'] . '.php', $this->container->getHome() . 'domain/' . basename($params['name']) . '.php')) { @chmod($this->container->getHome() . 'domain/' . basename($params['name']) . '.php', 0644); $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.doinstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy ' . $params['name'] . ' into destination ' . $this->container->getHome() . 'domain/' . basename($params['name']), \Innomatic\Logging\Logger::ERROR); } } } } if (!isset($params['icon'])) { $params['icon'] = ''; } if (strlen($params['icon'])) { $params['icon'] = $this->basedir . '/domain/' . $params['icon']; if (@copy($params['icon'], $this->container->getHome() . 'domain/' . basename($params['icon']))) { @chmod($this->container->getHome() . 'domain/' . basename($params['icon']), 0644); $result = true; } else { $this->mLog->logEvent('innomatic.domainpanel_component_domainpanelcomponent.doinstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to copy ' . $params['icon'] . ' into destination ' . $this->container->getHome() . 'domain/' . basename($params['icon']), \Innomatic\Logging\Logger::ERROR); } } 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; }
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; }
/** * 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 . '/'); }
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; }
/** * Redeploys a Module in the Module server. * * @param string $module Full path of the Module archive. * @return boolean * @since 5.1 */ public function redeploy($module) { $module = realpath($module); if (!file_exists($module)) { throw new \Innomatic\Module\ModuleException('Unable to find Module'); } $context = \Innomatic\Module\Server\ModuleServerContext::instance('\\Innomatic\\Module\\Server\\ModuleServerContext'); $tmp_dir = $context->getHome() . 'core/temp/appinst/deploy_' . rand() . DIRECTORY_SEPARATOR; mkdir($tmp_dir, 0755, true); if (is_dir($module)) { // Copies the Module directory \Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($module . '/', $tmp_dir); } else { // Unpacks the Module archive. $arc = new \Innomatic\Io\Archive\Archive($module, \Innomatic\Io\Archive\Archive::FORMAT_TAR); if (!$arc->extract($tmp_dir)) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); throw new \Innomatic\Module\ModuleException('Unable to extract Module'); } } // Checks if cmb.xml file exists. if (!file_exists($tmp_dir . 'setup/module.xml')) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); throw new \Innomatic\Module\ModuleException('Missing module.xml configuration file'); } // Parses Module configuration. $cfg = \Innomatic\Module\Util\ModuleXmlConfig::getInstance($tmp_dir . 'setup/module.xml'); if (!strlen($cfg->getName())) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); throw new \Innomatic\Module\ModuleException('Missing Module name in module.xml'); } // Checks if the Module to be redeployed exists in modules directory. if (!is_dir($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $cfg->getName())) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); throw new \Innomatic\Module\ModuleException('Module to be redeployed does not exists'); } // Checks Module code. $code_checker = new \Innomatic\Php\PHPCodeChecker(); if (!$code_checker->checkDirectory($tmp_dir)) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); throw new \Innomatic\Module\ModuleException('Module contains errors in code'); } // Removes old Module. if (is_dir($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $cfg->getName())) { \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $cfg->getName()); } // Deploys new Module. $module_dir = $context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $cfg->getName() . DIRECTORY_SEPARATOR; mkdir($module_dir, 0755, true); \Innomatic\Io\Filesystem\DirectoryUtils::dirCopy($tmp_dir . '/', $module_dir); \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($tmp_dir); // Executes Module redeploy hooked actions. //$auth = \Innomatic\Module\Server\ModuleServerAuthenticator::instance('ModuleServerAuthenticator'); //$module = \Innomatic\Module\ModuleFactory::getModule(new ModuleLocator('module://*****:*****@/'.$cfg->getName())); //$module->redeploy(); // Logs redeployment. 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($cfg->getName() . ' redeployed'); } 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'); $assetDestFolder = RootContainer::instance('\\Innomatic\\Core\\RootContainer')->getHome() . $domain . '/assets/' . basename($params['asset']) . '/'; if (!DirectoryUtils::dirCopy(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/assets/' . basename($params['asset']) . '/', $assetDestFolder)) { return false; } return true; }