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 doUpdateAction($params) { $result = false; if (strlen($params['file'])) { if (!file_exists(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . dirname($params['file']))) { \Innomatic\Io\Filesystem\DirectoryUtils::mktree(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . dirname($params['file']) . '/', 0755); } if (file_exists(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file'])) { unlink(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file']); } $file = $this->basedir . '/core/classes/' . $params['file']; if (file_exists($file)) { if (copy($file, InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/applications/' . $this->appname . '/classes/' . $params['file'])) { $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; }
/** * 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']); }
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 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; }
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 create($userdata) { $result = false; $userdata['username'] = str_replace(':', '', $userdata['username']); $userdata['username'] = str_replace('|', '', $userdata['username']); $userdata['username'] = str_replace('/', '', $userdata['username']); $userdata['username'] = str_replace('\\', '', $userdata['username']); // Default data if (!isset($userdata['fname'])) { $userdata['fname'] = ''; } if (!isset($userdata['lname'])) { $userdata['lname'] = ''; } if (!isset($userdata['otherdata'])) { $userdata['otherdata'] = ''; } if (!isset($userdata['email'])) { $userdata['email'] = ''; } $hook = new \Innomatic\Process\Hook($this->rootDA, 'innomatic', 'domain.user.add'); if ($hook->callHooks('calltime', $this, array('domainserial' => $this->domainserial, 'userdata' => $userdata)) == \Innomatic\Process\Hook::RESULT_OK) { if ($this->userid == 0) { $max_users_query = $this->rootDA->execute('SELECT maxusers,domainid FROM domains WHERE id=' . $userdata['domainid']); $goon = true; if ($max_users_query->getFields('maxusers')) { $users_num_query = $this->domainDA->execute('SELECT id FROM domain_users'); if ($users_num_query->getNumberRows() >= $max_users_query->getFields('maxusers')) { $goon = false; } } if ($goon) { // Check if the given username is unique $uquery = $this->domainDA->execute('SELECT * FROM domain_users WHERE username='******'username'])); if ($uquery->getNumberRows() == 0 & strlen($userdata['username']) > 0 & strlen($userdata['password']) > 0 & strlen($userdata['groupid']) > 0) { $seqval = $this->domainDA->getNextSequenceValue('domain_users_id_seq'); $user = '******' . $seqval . ','; $user .= $userdata['groupid'] . ','; $user .= $this->domainDA->formatText($userdata['username']) . ','; $user .= $this->domainDA->formatText(md5($userdata['password'])) . ','; $user .= $this->domainDA->formatText($userdata['fname']) . ','; $user .= $this->domainDA->formatText($userdata['lname']) . ','; $user .= $this->domainDA->formatText($userdata['otherdata']) . ','; $user .= $this->domainDA->formatText($userdata['email']) . ','; $user .= $this->domainDA->formatText($this->domainDA->fmtfalse) . ')'; $this->domainDA->execute($user); $this->userid = $seqval; $this->userExists = true; $result = $seqval; \Innomatic\Io\Filesystem\DirectoryUtils::mktree($this->container->getHome() . 'core/domains/' . $max_users_query->getFields('domainid') . '/users/' . $userdata['username'] . '/', 0755); if ($hook->callHooks('useradded', $this, array('domainserial' => $this->domainserial, 'userdata' => $userdata)) != \Innomatic\Process\Hook::RESULT_OK) { $result = false; } } } } } return $result; }