public function doUpdateAction($params)
 {
     $result = false;
     if (strlen($params['file'])) {
         $db_fact = new DataAccessFactory();
         $db_fact->updateDriver($params['name'], $params['desc']);
         $result = true;
     } else {
         $this->mLog->logEvent('innomatic.dataaccessdrivercomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty DataAccess driver file name', \Innomatic\Logging\Logger::ERROR);
     }
     return $result;
 }
 public static function setPassword($eventData, $log = '')
 {
     $result = false;
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     // Password setting
     //
     if (strlen($eventData['passworda']) and $eventData['passworda'] == $eventData['passwordb']) {
         // Creates Innomatic root password file
         //
         $fh = @fopen($container->getHome() . 'core/conf/rootpasswd.ini', 'w');
         if ($fh) {
             fputs($fh, md5($eventData['passworda']));
             fclose($fh);
             if (@touch($container->getHome() . 'core/temp/setup_passwordset', time())) {
                 if (isset($eventData['dbname']) and strlen($eventData['dbname'])) {
                     $args = $eventData;
                 } else {
                     $args['dbname'] = $container->getConfig()->value('RootDatabaseName');
                     $args['dbhost'] = $container->getConfig()->value('RootDatabaseHost');
                     $args['dbport'] = $container->getConfig()->value('RootDatabasePort');
                     $args['dbuser'] = $container->getConfig()->value('RootDatabaseUser');
                     $args['dbpass'] = $container->getConfig()->value('RootDatabasePassword');
                     $args['dbtype'] = $container->getConfig()->value('RootDatabaseType');
                     $args['dblog'] = $container->getHome() . 'core/log/innomatic_root_db.log';
                 }
                 $dasn_string = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog'];
                 $root_db = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasn_string));
                 if ($root_db->connect()) {
                     $modreg = new \Innomatic\Application\ApplicationComponentRegister($root_db);
                     $modreg->registerComponent('innomatic', 'configurationfile', 'rootpasswd.ini', '', \Innomatic\Application\ApplicationComponent::OVERRIDE_NONE);
                     $result = true;
                     if (file_exists($container->getHome() . 'core/temp/setup_settingpassword')) {
                         @unlink($container->getHome() . 'core/temp/setup_settingpassword');
                     }
                 } else {
                     $log->logevent('innomatic.root.main_php', 'Unable to connect to Innomatic database during initialization', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log->logevent('innomatic.root.main_php', 'Unable to create .passwordset lock file during initialization', \Innomatic\Logging\Logger::ERROR);
             }
         } else {
             $log->logevent('innomatic.root.main_php', 'Unable to create root password file', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }
 /**
  * Bootstraps the Innomatic container.
  *
  * @param string $home Complete path of the directory containing the
  * Innomatic webapp.
  * @param string $configuration Complete path of the Innomatic
  * configuration file.
  */
 public function bootstrap($home, $configuration)
 {
     if ($this->bootstrapped) {
         return;
     }
     $this->home = $home;
     // Reads the configuration
     $this->configurationFile = $configuration;
     $this->config = new InnomaticSettings($configuration);
     // *********************************************************************
     // PHP environment
     // *********************************************************************
     // PHP
     $timelimit = $this->config->value('PHPExecutionTimeLimit');
     if (!strlen($timelimit)) {
         $timelimit = 0;
     }
     set_time_limit($timelimit);
     ignore_user_abort(true);
     // Adds global override classes folder to the include path.
     set_include_path($this->home . 'core/overrides/classes/' . PATH_SEPARATOR . get_include_path());
     // *********************************************************************
     // Innomatic state, environment, mode, interface and edition
     // *********************************************************************
     // Waits until system is in upgrade phase
     if ($this->lockOverride == false) {
         while (file_exists($this->home . 'core/temp/upgrading_system_lock')) {
             $this->state = \Innomatic\Core\InnomaticContainer::STATE_UPGRADE;
             clearstatcache();
             sleep(1);
         }
     }
     // Checks if system is in setup phase and sets the state
     if (file_exists($this->home . 'core/temp/setup_lock')) {
         $this->state = \Innomatic\Core\InnomaticContainer::STATE_SETUP;
         if (extension_loaded('APD')) {
             apd_set_session_trace(35);
         }
     } else {
         switch ($this->config->value('PlatformState')) {
             case 'debug':
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_DEBUG;
                 if (extension_loaded('APD')) {
                     apd_set_session_trace(35);
                 }
                 break;
             case 'production':
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_PRODUCTION;
                 break;
             default:
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_PRODUCTION;
         }
     }
     // Environment
     switch ($this->config->value('PlatformEnvironment')) {
         case 'development':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_DEVELOPMENT;
             break;
         case 'integration':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_INTEGRATION;
             break;
         case 'staging':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_STAGING;
             break;
         case 'production':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_PRODUCTION;
             break;
         default:
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_PRODUCTION;
     }
     // Interface
     //$this->interface = \Innomatic\Core\InnomaticContainer::INTERFACE_UNKNOWN;
     // Mode
     //$this->mode = \Innomatic\Core\InnomaticContainer::MODE_ROOT;
     // Edition
     if ($this->config->value('PlatformEdition') == 'enterprise' or $this->config->value('PlatformEdition') == 'singletenant') {
         $this->edition = \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT;
     }
     // *********************************************************************
     // Pid and shutdown function
     // *********************************************************************
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $this->pid = md5(microtime());
         if (!file_exists($this->home . 'core/temp/pids/')) {
             @mkdir($this->home . 'core/temp/pids/');
         }
         touch($this->home . 'core/temp/pids/' . $this->pid, time());
         register_shutdown_function(array($this, 'shutdown'));
     }
     // *********************************************************************
     // Innomatic platform name
     // *********************************************************************
     $this->platformName = $this->config->value('PlatformName');
     $this->platformGroup = $this->config->value('PlatformGroup');
     // *********************************************************************
     // Innomatic error handler
     // *********************************************************************
     //set_error_handler(array($this, 'errorHandler'));
     // *********************************************************************
     // Innomatic root
     // *********************************************************************
     $this->country = $this->config->value('RootCountry');
     $this->language = $this->config->value('RootLanguage');
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         // Innomatic central database
         //
         $dasnString = $this->config->value('RootDatabaseType') . '://' . $this->config->value('RootDatabaseUser') . ':' . $this->config->value('RootDatabasePassword') . '@' . $this->config->value('RootDatabaseHost') . ':' . $this->config->value('RootDatabasePort') . '/' . $this->config->value('RootDatabaseName') . '?' . 'logfile=' . $this->getHome() . 'core/log/innomatic_root_db.log';
         $this->rootDb = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasnString));
         if (!$this->rootDb->connect()) {
             $this->abort('Database not connected');
         }
     }
     // *********************************************************************
     // Run time state and interface defined data
     // *********************************************************************
     // Debugger
     if ($this->state == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $this->loadTimer = new \Innomatic\Debug\LoadTime(LoadTime::LOADTIME_MODE_CONTINUOUS);
         $this->loadTimer->Mark('start');
         $this->dbLoadTimer = new \Innomatic\Debug\LoadTime(LoadTime::LOADTIME_MODE_STARTSTOP);
     }
     // Security
     $securityReportsInterval = $this->config->value('SecurityReportsInterval');
     if ($securityReportsInterval > 0) {
         $lastSecurityReport = $this->config->value('SecurityLastReportTime');
         if (!$lastSecurityReport or $lastSecurityReport < time() - $securityReportsInterval * 3600 * 24) {
             $innomaticSecurity = new \Innomatic\Security\SecurityManager();
             $innomaticSecurity->sendReport();
             unset($innomaticSecurity);
         }
     }
     unset($securityReportsInterval);
     // Maintenance
     $maintenanceHandler = new \Innomatic\Maintenance\MaintenanceHandler();
     $maintenanceInterval = $maintenanceHandler->getMaintenanceInterval();
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_MAINTENANCE and $maintenanceInterval > 0) {
         $lastMaintenance = $maintenanceHandler->getLastMaintenanceTime();
         if (!$lastMaintenance or $lastMaintenance < time() - $maintenanceInterval * 3600 * 24) {
             $innomaticMaintenance = new \Innomatic\Maintenance\MaintenanceHandler();
             $innomaticMaintenance->doMaintenance();
             $innomaticMaintenance->sendReport();
             unset($innomaticMaintenance);
         }
     }
     unset($maintenanceInterval);
     // *********************************************************************
     // Auto exec routines
     // *********************************************************************
     // Application reupdate check
     if (file_exists($this->home . 'core/temp/appinst/reupdate')) {
         $tmpmod = new \Innomatic\Application\Application($this->rootDb, '');
         $tmpmod->install($this->home . 'core/temp/appinst/reupdate');
         clearstatcache();
         if (file_exists($this->home . 'core/temp/appinst/reupdate')) {
             unlink($this->home . 'core/temp/appinst/reupdate');
         }
     }
     // Startup hook
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $hook = new \Innomatic\Process\Hook($this->rootDb, 'innomatic', 'instance');
         $null = '';
         switch ($hook->callHooks('startup', $null, '')) {
             case \Innomatic\Process\Hook::RESULT_ABORT:
                 $this->abort('Bootstrap aborted');
                 break;
         }
     }
     // Bootstrap end
     $this->bootstrapped = true;
 }
Example #4
0
 public function disable($domainid)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'application.disable');
     if ($hook->callHooks('calltime', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) == \Innomatic\Process\Hook::RESULT_OK) {
         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();
                 if ($appdata['onlyextension'] != $this->rootda->fmttrue) {
                     // Checks if the structure file still exists
                     //
                     if (file_exists($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml')) {
                         $this->appname = $appdata['appid'];
                         $domainquery = $this->rootda->execute('SELECT * FROM domains WHERE id=' . $this->rootda->formatText((int) $domainid));
                         $domaindata = $domainquery->getFields();
                         if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) {
                             $args['dbtype'] = $domaindata['dataaccesstype'];
                             $args['dbname'] = $domaindata['domaindaname'];
                             $args['dbhost'] = $domaindata['dataaccesshost'];
                             $args['dbport'] = $domaindata['dataaccessport'];
                             $args['dbuser'] = $domaindata['dataaccessuser'];
                             $args['dbpass'] = $domaindata['dataaccesspassword'];
                             $args['dblog'] = $this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log/dataaccess.log';
                             $dasnString = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog'];
                             $this->domainda = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasnString));
                             $this->domainda->Connect();
                         } else {
                             $this->domainda = $this->rootda;
                         }
                         // Dependencies check
                         //
                         $this->unmetdeps = array();
                         $this->unmetsuggs = array();
                         $appdeps = new ApplicationDependencies();
                         $pendingdeps = $appdeps->checkDomainDependingApplications($this->appname, $domaindata['domainid'], false);
                         $modenabled = $appdeps->isEnabled($this->appname, $domaindata['domainid']);
                         // If dependencies are ok, go on
                         //
                         if ($pendingdeps == false and $modenabled == true) {
                             $result = $this->HandleStructure($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml', Application::INSTALL_MODE_DISABLE, $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/', $domainid);
                             $modquery = $this->rootda->execute('SELECT id FROM applications WHERE appid=' . $this->rootda->formatText($this->appname));
                             $this->rootda->execute('DELETE FROM applications_enabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . $this->rootda->formatText($domainid));
                             $this->rootda->execute('DELETE FROM applications_options_disabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . (int) $domainid);
                             if ($this->container->getConfig()->Value('SecurityAlertOnApplicationDomainOperation') == '1') {
                                 $innomaticSecurity = new \Innomatic\Security\SecurityManager();
                                 $innomaticSecurity->sendAlert('Application ' . $appdata['appid'] . ' has been disabled from domain ' . $domaindata['domainid']);
                                 unset($innomaticSecurity);
                             }
                             if ($hook->callHooks('applicationdisabled', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) != \Innomatic\Process\Hook::RESULT_OK) {
                                 $result = false;
                             }
                         } elseif ($modenabled == false) {
                         } else {
                             $this->unmetdeps = $pendingdeps;
                         }
                         //if ( $result == true ) $this->mLog->logEvent(
                         //    'Innomatic',
                         //    'Uninstalled application '.$this->appname,
                         //    \Innomatic\Logging\Logger::NOTICE
                         //);
                         $domainquery->free();
                     } else {
                         $log = $this->container->getLogger();
                         $log->logEvent('innomatic.applications.applications.disable', '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.disable', 'Tried to disable application ' . $appdata['appid'] . ', but it is an extension only application', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log = $this->container->getLogger();
                 $log->logEvent('innomatic.applications.applications.disable', '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.disable', 'Empty application serial', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }
Example #5
0
 public function create($domaindata, $createDb = true)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'domain.create');
     if ($hook->callHooks('calltime', $this, array('domaindata' => $domaindata)) == \Innomatic\Process\Hook::RESULT_OK) {
         $domaindata['domainid'] = strtolower(str_replace(' ', '', trim($domaindata['domainid'])));
         // Checks if the domainid contains reserved words.
         if (in_array($domaindata['domainid'], $this->reservedNames)) {
             $log = $this->container->getLogger();
             $log->logEvent('innomatic.domain.create', 'Cannot create domain with id "' . $domaindata['domainid'] . '" since it is a reserved word', \Innomatic\Logging\Logger::WARNING);
             return false;
         }
         // When in enterprise edition, checks if there are no domains.
         $goon = true;
         if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT) {
             $check_query = $this->container->getDataAccess()->execute('SELECT count(*) AS domains FROM domains');
             if ($check_query->getFields('domains') > 0) {
                 $goon = false;
             }
         }
         if ($goon) {
             // Default settings and settings tuning
             //
             $nextseq = $this->rootda->getNextSequenceValue('domains_id_seq');
             // Set database name prefix
             $platformName = $this->container->getPlatformName();
             if (!strlen($platformName)) {
                 // Default prefix
                 $platformName = 'innomatic';
             } else {
                 $platformName = strtolower($platformName);
                 // Remove empty spaces
                 $platformName = str_replace(' ', '', $platformName);
                 // Remove accented characters
                 $platformName = iconv("utf-8", "ascii//TRANSLIT", $platformName);
             }
             // TODO check that the domainid doesn't contain unsupported characters.
             $domaindata['domainid'] = $this->defopt($domaindata['domainid'], $nextseq);
             $domaindata['domainname'] = $this->defopt(trim($domaindata['domainname']), $domaindata['domainid'] . ' domain');
             $domaindata['domainpassword'] = $this->defopt(trim($domaindata['domainpassword']), $domaindata['domainid']);
             $domaindata['domaindaname'] = $this->defopt(strtolower(str_replace(' ', '', trim($domaindata['domaindaname']))), $platformName . '_' . $domaindata['domainid'] . '_tenant');
             $domaindata['dataaccesshost'] = $this->defopt(trim($domaindata['dataaccesshost']), $this->container->getConfig()->value('RootDatabaseHost'));
             $domaindata['dataaccessport'] = $this->defopt(trim($domaindata['dataaccessport']), $this->container->getConfig()->value('RootDatabasePort'));
             $domaindata['dataaccessuser'] = $this->defopt(str_replace(' ', '', trim($domaindata['dataaccessuser'])), $this->container->getConfig()->value('RootDatabaseUser'));
             $domaindata['dataaccesspassword'] = $this->defopt(trim($domaindata['dataaccesspassword']), $this->container->getConfig()->value('RootDatabasePassword'));
             $domaindata['dataaccesstype'] = $this->defopt(trim($domaindata['dataaccesstype']), $this->container->getConfig()->value('RootDatabaseType'));
             $domaindata['domaincreationdate'] = isset($domaindata['domaincreationdate']) ? trim($domaindata['domaincreationdate']) : time();
             $domaindata['domainexpirydate'] = isset($domaindata['domainexpirytime']) ? trim($domaindata['domainexpirydate']) : time();
             $domaindata['domainactive'] = isset($domaindata['domainactive']) ? $domaindata['domainactive'] : $this->rootda->fmttrue;
             $domaindata['maxusers'] = isset($domaindata['maxusers']) ? $domaindata['maxusers'] : '0';
             if (!isset($domaindata['domainnotes'])) {
                 $domaindata['domainnotes'] = '';
             }
             $domaindata['webappskeleton'] = $this->defopt(trim($domaindata['webappskeleton']), 'default');
             if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT) {
                 $domaindata['domaindaname'] = $this->container->getConfig()->value('RootDatabaseName');
                 $domaindata['dataaccesshost'] = $this->container->getConfig()->value('RootDatabaseHost');
                 $domaindata['dataaccessport'] = $this->container->getConfig()->value('RootDatabasePort');
                 $domaindata['dataaccessuser'] = $this->container->getConfig()->value('RootDatabaseUser');
                 $domaindata['dataaccesspassword'] = $this->container->getConfig()->value('RootDatabasePassword');
                 $domaindata['dataaccesstype'] = $this->container->getConfig()->value('RootDatabaseType');
             }
             if ($this->rootda->execute('INSERT INTO domains VALUES ( ' . $nextseq . ',' . $this->rootda->formatText($domaindata['domainid']) . ',' . $this->rootda->formatText($domaindata['domainname']) . ',' . $this->rootda->formatText(md5($domaindata['domainpassword'])) . ',' . $this->rootda->formatText($domaindata['domaindaname']) . ',' . $this->rootda->formatText($domaindata['dataaccesshost']) . ',' . $this->rootda->formatInteger($domaindata['dataaccessport']) . ',' . $this->rootda->formatText($domaindata['dataaccessuser']) . ',' . $this->rootda->formatText($domaindata['dataaccesspassword']) . ',' . $this->rootda->formatText($domaindata['dataaccesstype']) . ',' . $this->rootda->formatDate($domaindata['domaincreationdate']) . ',' . $this->rootda->formatDate($domaindata['domainexpirydate']) . ',' . $this->rootda->formatText($domaindata['domainactive']) . ',' . $this->rootda->formatText($domaindata['domainnotes']) . ',' . $this->rootda->formatInteger($domaindata['maxusers']) . ',' . $this->rootda->formatText($domaindata['webappskeleton']) . ',' . $this->rootda->formatText($domaindata['webappurl']) . ')')) {
                 $this->domainid = $domaindata['domainid'];
                 $this->domainserial = $nextseq;
                 $this->domainlog = new \Innomatic\Logging\Logger($this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log/domain.log');
                 // Domain private directory tree creation inside Innomatic webapp.
                 $this->makedir($this->container->getHome() . 'core/domains/' . $domaindata['domainid']);
                 $this->makedir($this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log');
                 $this->makedir($this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/conf');
                 // Domain webapp creation.
                 \Innomatic\Webapp\WebAppContainer::createWebApp($domaindata['domainid'], $domaindata['webappskeleton']);
                 // Creates the database, if asked.
                 if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) {
                     $args['dbtype'] = strlen($domaindata['dataaccesstype']) ? $domaindata['dataaccesstype'] : $this->container->getConfig()->value('RootDatabaseType');
                     $args['dbname'] = $domaindata['domaindaname'];
                     $args['dbhost'] = $domaindata['dataaccesshost'];
                     $args['dbport'] = $domaindata['dataaccessport'];
                     $args['dbuser'] = $domaindata['dataaccessuser'];
                     $args['dbpass'] = $domaindata['dataaccesspassword'];
                     $args['dblog'] = $this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log/dataaccess.log';
                     $args['name'] = $domaindata['domaindaname'];
                     $dasn_string = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog'];
                     $tmpdb = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasn_string));
                     if ($createDb) {
                         if ($tmpdb->connect()) {
                             $tmpdb->dropDB($args);
                             $tmpdb->close();
                         }
                     }
                 } else {
                     $tmpdb = $this->rootda;
                 }
                 if (!$createDb or $this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT or $created = $tmpdb->createDB($args)) {
                     if (isset($created) and $created == true) {
                         $this->domainlog->logEvent($domaindata['domainid'], 'Database ' . $args['dbname'] . ' created', \Innomatic\Logging\Logger::NOTICE);
                     }
                     if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT or $tmpdb->connect()) {
                         if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) {
                             $this->dataAccess = $tmpdb;
                         } else {
                             $this->dataAccess = $this->rootda;
                         }
                         //$xmldb = new DataAccessXmlTable( $tmpdb, DataAccessXmlTable::SQL_CREATE );
                         $this->container->setCurrentDomain($this);
                         // Prepares the domain admin user to be created later
                         $tmpuser = new \Innomatic\Domain\User\User($nextseq);
                         $this->container->setCurrentUser($tmpuser);
                         $tmpquery = $this->rootda->execute('SELECT id FROM applications WHERE appid=' . $this->rootda->formatText('innomatic'));
                         if ($this->enableApplication($tmpquery->getFields('id'))) {
                             // Create the administrator user
                             $tmpuser->createAdminUser($domaindata['domainid'], $domaindata['domainpassword']);
                             $log = $this->container->getLogger();
                             $log->logEvent($domaindata['domainid'], 'Created new domain ' . $domaindata['domainid'], \Innomatic\Logging\Logger::NOTICE);
                             $this->domainlog->logEvent($domaindata['domainid'], 'Created domain ' . $domaindata['domainid'], \Innomatic\Logging\Logger::NOTICE);
                             if ($hook->callHooks('domaincreated', $this, array('domaindata' => $domaindata)) != \Innomatic\Process\Hook::RESULT_ABORT) {
                                 $result = true;
                             }
                             if ($this->container->getConfig()->Value('SecurityAlertOnDomainOperation') == '1') {
                                 $innomatic_security = new \Innomatic\Security\SecurityManager();
                                 $innomatic_security->sendAlert('A domain has been created with id ' . $domaindata['domainid']);
                                 unset($innomatic_security);
                             }
                         } else {
                             $log = $this->container->getLogger();
                             $log->logEvent('innomatic.domains.domain.create', 'Unable to enable Innomatic to the domain', \Innomatic\Logging\Logger::ERROR);
                         }
                     } else {
                         $log = $this->container->getLogger();
                         $log->logEvent('innomatic.domains.domain.create', 'Unable to connect to domain database', \Innomatic\Logging\Logger::ERROR);
                     }
                 } else {
                     $log = $this->container->getLogger();
                     $log->logEvent('innomatic.domains.domain.create', 'Unable to create domain database', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log = $this->container->getLogger();
                 $log->logEvent('innomatic.domains.domain.create', 'Unable to insert domain row in domains table', \Innomatic\Logging\Logger::ERROR);
             }
         } else {
             $log = $this->container->getLogger();
             $log->logEvent('innomatic.domains.domain.create', 'Tried to create another domain in Enterprise edition', \Innomatic\Logging\Logger::WARNING);
         }
     }
     return $result;
 }
Example #6
0
 if (!file_exists($container->getHome() . 'core/temp/setup_languageset')) {
     @touch($container->getHome() . 'core/temp/setup_settinglanguage', time());
     $pass_data = $actionDispatcher->getEventData();
     $country = isset($pass_data['country']) ? $pass_data['country'] : '';
     if (!strlen($country)) {
         $country = $container->getCountry();
     }
     $args['dbname'] = $container->getConfig()->value('RootDatabaseName');
     $args['dbhost'] = $container->getConfig()->value('RootDatabaseHost');
     $args['dbport'] = $container->getConfig()->value('RootDatabasePort');
     $args['dbuser'] = $container->getConfig()->value('RootDatabaseUser');
     $args['dbpass'] = $container->getConfig()->value('RootDatabasePassword');
     $args['dbtype'] = $container->getConfig()->value('RootDatabaseType');
     $args['dblog'] = $container->getHome() . 'core/log/innomatic_root_db.log';
     $dasn_string = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog'];
     $tmpdb = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasn_string));
     if ($tmpdb->Connect()) {
         $loc_country = new \Innomatic\Locale\LocaleCountry($country);
         $country_language = $loc_country->Language();
         $language_locale = new \Innomatic\Locale\LocaleCatalog('innomatic::localization', $container->getLanguage());
         $selected_language = $actionDispatcher->getEventData();
         if (isset($selected_language['language'])) {
             $selected_language = $selected_language['language'];
         } else {
             $selected_language = false;
         }
         $wui_vgroup = new WuiVertgroup('vgroup');
         $language_query = $tmpdb->execute('SELECT * FROM locale_languages');
         while (!$language_query->eof) {
             $languages[$language_query->getFields('langshort')] = $language_locale->getStr($language_query->getFields('langname'));
             $language_query->moveNext();
 public function viewShowDomainConfig($eventData)
 {
     $dbtypes = \Innomatic\Dataaccess\DataAccessFactory::getDrivers();
     $query = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT * FROM domains WHERE id=' . $eventData['domainid']);
     if ($query->getNumberRows()) {
         $domainData = $query->getFields();
         // Retrieves the webapp skeleton catalog and localized name.
         $skeletonsQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT catalog FROM webapps_skeletons ' . 'WHERE name=' . \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->formatText($domainData['webappskeleton']));
         $tmpLocale = new \Innomatic\Locale\LocaleCatalog($skeletonsQuery->getFields('catalog'), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getLanguage());
         $skeletonName = $tmpLocale->getStr($domainData['webappskeleton']);
         $wuiVGroup = new WuiVertgroup('vgroup');
         $wuiDomainGrid = new WuiGrid('showdomaingrid', array('rows' => '6', 'cols' => '4'));
         // Domain fields
         //
         $wuiDomainGrid->addChild(new WuiLabel('basedatalabel', array('label' => $this->_localeCatalog->getStr('domain_base_data'), 'bold' => 'true')), 0, 0);
         $wuiDomainGrid->addChild(new WuiLabel('namelabel', array('label' => $this->_localeCatalog->getStr('domainname_label'))), 1, 0);
         $wuiDomainGrid->addChild(new WuiString('domainname', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['domainname'])), 1, 1);
         $wuiDomainGrid->addChild(new WuiLabel('idlabel', array('label' => $this->_localeCatalog->getStr('domainid_label'))), 2, 0);
         $wuiDomainGrid->addChild(new WuiString('domainid', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['domainid'])), 2, 1);
         $wuiDomainGrid->addChild(new WuiLabel('maxuserslabel', array('label' => $this->_localeCatalog->getStr('maxusers_label'))), 3, 0);
         $wuiDomainGrid->addChild(new WuiString('maxusers', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['maxusers'])), 3, 1);
         $wuiDomainGrid->addChild(new WuiLabel('basedatalabel', array('label' => $this->_localeCatalog->getStr('webapp_data'), 'bold' => 'true')), 4, 0);
         $wuiDomainGrid->addChild(new WuiLabel('webappskeletonlabel', array('label' => $this->_localeCatalog->getStr('webappskeleton_label'))), 5, 0);
         $wuiDomainGrid->addChild(new WuiString('webappskeleton', array('disp' => 'action', 'readonly' => 'true', 'value' => $skeletonName)), 5, 1);
         $wuiDomainGrid->addChild(new WuiLabel('urllabel', array('label' => $this->_localeCatalog->getStr('webappurl_label'))), 6, 0);
         $wuiDomainGrid->addChild(new WuiString('webappurl', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['webappurl'])), 6, 1);
         if (\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) {
             // Database fields
             //
             $wuiDomainGrid->addChild(new WuiLabel('basedatalabel', array('label' => $this->_localeCatalog->getStr('database_data'), 'bold' => 'true')), 0, 2);
             $wuiDomainGrid->addChild(new WuiLabel('dbtypelabel', array('label' => $this->_localeCatalog->getStr('dataaccesstype_label'))), 1, 2);
             $wuiDomainGrid->addChild(new WuiString('dataaccesstype', array('disp' => 'action', 'readonly' => 'true', 'value' => $dbtypes[$domainData['dataaccesstype']])), 1, 3);
             $wuiDomainGrid->addChild(new WuiLabel('dbnamelabel', array('label' => $this->_localeCatalog->getStr('domaindaname_label'))), 2, 2);
             $wuiDomainGrid->addChild(new WuiString('domaindaname', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['domaindaname'])), 2, 3);
             $wuiDomainGrid->addChild(new WuiLabel('dbhostlabel', array('label' => $this->_localeCatalog->getStr('dataaccesshost_label'))), 3, 2);
             $wuiDomainGrid->addChild(new WuiString('dataaccesshost', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['dataaccesshost'])), 3, 3);
             $wuiDomainGrid->addChild(new WuiLabel('dbportlabel', array('label' => $this->_localeCatalog->getStr('dataaccessport_label'))), 4, 2);
             $wuiDomainGrid->addChild(new WuiString('dataaccessport', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['dataaccessport'])), 4, 3);
             $wuiDomainGrid->addChild(new WuiLabel('dbuserlabel', array('label' => $this->_localeCatalog->getStr('dataaccessuser_label'))), 5, 2);
             $wuiDomainGrid->addChild(new WuiString('dataaccessuser', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['dataaccessuser'])), 5, 3);
             $wuiDomainGrid->addChild(new WuiLabel('dbpasswordlabel', array('label' => $this->_localeCatalog->getStr('dataaccesspassword_label'))), 6, 2);
             $wuiDomainGrid->addChild(new WuiString('dataaccesspassword', array('disp' => 'action', 'readonly' => 'true', 'value' => $domainData['dataaccesspassword'])), 6, 3);
         }
         $wuiVGroup->addChild($wuiDomainGrid);
         $this->wuiMainframe->addChild($wuiVGroup);
     }
     $this->wuiTitlebar->mArgs['title'] .= ' - ' . $this->_localeCatalog->getStr('showdomainconfig_title');
 }