示例#1
0
 public function saveSystemConf($httpData)
 {
     G::loadClass('system');
     $envFile = PATH_CONFIG . 'env.ini';
     $updateRedirector = false;
     $restart = false;
     if (!file_exists($envFile)) {
         // if ini file doesn't exists
         if (!is_writable(PATH_CONFIG)) {
             throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config');
         }
         $content = ";\r\n";
         $content .= "; ProcessMaker System Bootstrap Configuration\r\n";
         $content .= ";\r\n";
         file_put_contents($envFile, $content);
         //@chmod($envFile, 0777);
     } else {
         if (!is_writable($envFile)) {
             throw new Exception('The enviroment ini file file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini');
         }
     }
     $sysConf = System::getSystemConfiguration($envFile);
     $updatedConf = array();
     if ($sysConf['default_lang'] != $httpData->default_lang) {
         $updatedConf['default_lang'] = $sysConf['default_lang'] = $httpData->default_lang;
         $updateRedirector = true;
     }
     if ($sysConf['default_skin'] != $httpData->default_skin) {
         $updatedConf['default_skin'] = $sysConf['default_skin'] = $httpData->default_skin;
         $updateRedirector = true;
     }
     if ($sysConf['time_zone'] != $httpData->time_zone) {
         $updatedConf['time_zone'] = $httpData->time_zone;
     }
     $httpData->memory_limit .= 'M';
     if ($sysConf['memory_limit'] != $httpData->memory_limit) {
         $updatedConf['memory_limit'] = $httpData->memory_limit;
     }
     if ($updateRedirector) {
         if (!file_exists(PATH_HTML . 'index.html')) {
             throw new Exception('The index.html file is not writable on workflow/public_html directory.');
         } else {
             if (!is_writable(PATH_HTML . 'index.html')) {
                 throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html');
             }
         }
         System::updateIndexFile(array('lang' => $sysConf['default_lang'], 'skin' => $sysConf['default_skin']));
         $restart = true;
     }
     G::update_php_ini($envFile, $updatedConf);
     if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
         $urlPart = '/main/login';
     } else {
         $urlPart = '/login/login';
     }
     $this->success = true;
     $this->restart = $restart;
     $this->url = '/sys' . SYS_SYS . '/' . $sysConf['default_lang'] . '/' . $sysConf['default_skin'] . $urlPart;
     $this->message = 'Saved Successfully';
 }
示例#2
0
 public static function browserCacheFilesSetUid()
 {
     $uid = G::generateUniqueID();
     $arrayData = array();
     $arrayData["browser_cache_files_uid"] = $uid;
     G::update_php_ini(PATH_CONFIG . "env.ini", $arrayData);
 }
示例#3
0
    public function createMySQLWorkspace ()

    {

        G::LoadSystem('inputfilter');

        $filter = new InputFilter();

        ini_set( 'max_execution_time', '0' );

        $info = new StdClass();

        $info->result = false;

        $info->message = '';

        $info->canRedirect = true;



        $db_hostname = trim( $_REQUEST['db_hostname'] );

        $db_port = trim( $_REQUEST['db_port'] );

        $db_port = $filter->validateInput($db_port);

        $db_username = trim( $_REQUEST['db_username'] );

        $db_username = $filter->validateInput($db_username);

        $db_password = trim( $_REQUEST['db_password'] );

        $db_password = $filter->validateInput($db_password);

        $wf = trim( $_REQUEST['wfDatabase'] );

        $rb = trim( $_REQUEST['wfDatabase'] );

        $rp = trim( $_REQUEST['wfDatabase'] );

        $workspace = trim( $_REQUEST['workspace'] );

        $pathConfig = trim( $_REQUEST['pathConfig'] );

        $pathLanguages = trim( $_REQUEST['pathLanguages'] );

        $pathPlugins = trim( $_REQUEST['pathPlugins'] );

        $pathShared = trim( $_REQUEST['pathShared'] );

        $pathXmlforms = trim( $_REQUEST['pathXmlforms'] );

        $adminPassword = trim( $_REQUEST['adminPassword'] );

        $adminPassword = $filter->validateInput($adminPassword);

        $adminUsername = trim( $_REQUEST['adminUsername'] );

        $adminUsername = $filter->validateInput($adminUsername);

        $deleteDB = ($_REQUEST['deleteDB'] == 'true');

        $userLogged = (isset($_REQUEST['userLogged']) ? ($_REQUEST['userLogged'] == 'true') : false);

        $userLogged = $filter->validateInput($userLogged);



        if (substr( $pathShared, - 1 ) != '/') {

            $pathShared .= '/';

        }



        $this->installLog( '-------------------------------------------' );

        $this->installLog( G::LoadTranslation('ID_CREATING_WORKSPACE', SYS_LANG, Array($workspace)));



        try {

            $db_host = ($db_port != '' && $db_port != 3306) ? $db_hostname . ':' . $db_port : $db_hostname;

            $db_host = $filter->validateInput($db_host);

            $db_username = $filter->validateInput($db_username);

            $db_password = $filter->validateInput($db_password);

            $this->link = @mysql_connect( $db_host, $db_username, $db_password );

            $this->installLog( G::LoadTranslation('ID_CONNECT_TO_SERVER', SYS_LANG, Array($db_hostname, $db_port, $db_username ) ));



            if ($deleteDB) {

                $q = sprintf( 'DROP DATABASE IF EXISTS %s;', $wf, $wf );

                $this->mysqlQuery( $q );

            }



            // CREATE databases wf_workflow, rb_workflow and rp_workflow

            $q = sprintf( 'CREATE DATABASE IF NOT EXISTS %s;', $wf, $wf );

            $this->mysqlQuery( $q );



            // CREATE users and GRANT Privileges

            $wf_workpace = $wf;

            $rb_workpace = $wf;

            $rp_workpace = $wf;

            if (!$userLogged) {

                $wfPass = G::generate_password( 12 );

                $this->setGrantPrivilegesMySQL( $wf, $wfPass, $wf, $db_hostname );

                $this->setGrantPrivilegesMySQL( $rb, $wfPass, $wf, $db_hostname );

                $this->setGrantPrivilegesMySQL( $rp, $wfPass, $wf, $db_hostname );

            } else {

                $wfPass = $db_password;

                $rbPass = $db_password;

                $rpPass = $db_password;

                $wf = $db_username;

                $rb = $db_username;

                $rp = $db_username;

            }





            // Generate the db.php file and folders

            $pathSharedSites = $pathShared;

            $path_site = $pathShared . "/sites/" . $workspace . "/";

            $db_file = $path_site . "db.php";

            @mkdir( $path_site, 0777, true );

            @mkdir( $path_site . "files/", 0777, true );

            @mkdir( $path_site . "mailTemplates/", 0777, true );

            @mkdir( $path_site . "public/", 0777, true );

            @mkdir( $path_site . "reports/", 0777, true );

            @mkdir( $path_site . "xmlForms", 0777, true );



            $dbText = "<?php\n";

            $dbText .= sprintf( "// Processmaker configuration\n" );

            $dbText .= sprintf( "  define ('DB_ADAPTER',     '%s' );\n", 'mysql' );

            $dbText .= sprintf( "  define ('DB_HOST',        '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_NAME',        '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_USER',        '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_PASS',        '%s' );\n", $wfPass );

            $dbText .= sprintf( "  define ('DB_RBAC_HOST',   '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_RBAC_NAME',   '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_RBAC_USER',   '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_RBAC_PASS',   '%s' );\n", $wfPass );

            $dbText .= sprintf( "  define ('DB_REPORT_HOST', '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_REPORT_NAME', '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_REPORT_USER', '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_REPORT_PASS', '%s' );\n", $wfPass );



            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $dbText .= "\n";

                $dbText .= "  define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG')) ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n";

                if ($this->systemName != '') {

                    $dbText .= "  define ('SYSTEM_NAME', '" . $this->systemName . "');\n";

                }

            }



            $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($db_file) ));

            file_put_contents( $db_file, $dbText );



            // Generate the databases.php file

            $databases_file = $path_site . 'databases.php';

            $dbData = sprintf( "\$dbAdapter    = '%s';\n", 'mysql' );

            $dbData .= sprintf( "\$dbHost       = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbName       = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbUser       = '******';\n", $wf );

            $dbData .= sprintf( "\$dbPass       = '******';\n", $wfPass );

            $dbData .= sprintf( "\$dbRbacHost   = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbRbacName   = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbRbacUser   = '******';\n", $wf );

            $dbData .= sprintf( "\$dbRbacPass   = '******';\n", $wfPass );

            $dbData .= sprintf( "\$dbReportHost = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbReportName = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbReportUser = '******';\n", $wf );

            $dbData .= sprintf( "\$dbReportPass = '******';\n", $wfPass );

            $databasesText = str_replace( '{dbData}', $dbData, @file_get_contents( PATH_HOME . 'engine/templates/installer/databases.tpl' ) );



            $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($databases_file) ));

            file_put_contents( $databases_file, $databasesText );



            // Execute scripts to create and populates databases

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );



            $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/schema.sql' );

            $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/insert.sql' );

            

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );

            $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/schema.sql' );

            $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/insert.sql' );

            



            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $this->setPartner();

                //$this->setConfiguration();

            }



            // Create the triggers

            if (file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' )) {

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) );

                $this->mysqlQuery(@file_get_contents(PATH_HOME . "engine/methods/setup/setupSchemas/triggerSubApplicationInsert.sql"));

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' ) );



                $this->mysqlQuery( "INSERT INTO `CONFIGURATION` (

                            `CFG_UID`,

                            `CFG_VALUE`

                           )

                           VALUES (

                             'APP_CACHE_VIEW_ENGINE',

                             '" . mysql_real_escape_string( serialize( array ('LANG' => 'en','STATUS' => 'active'

                ) ) ) . "'

                           )" );



                $this->mysqlQuery("INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')");

            }



            // Change admin user

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );



            $query = sprintf( "UPDATE USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) );

            $this->mysqlQuery( $query );



            $query = sprintf( "UPDATE RBAC_USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) );

            $this->mysqlQuery( $query );



            // Write the paths_installed.php file (contains all the information configured so far)

            if (! file_exists( FILE_PATHS_INSTALLED )) {

                $sh = G::encryptOld( filemtime( PATH_GULLIVER . '/class.g.php' ) );

                $h = G::encrypt( $db_hostname . $sh . $db_username . $sh . $db_password, $sh );

                $dbText = "<?php\n";

                $dbText .= sprintf( "  define('PATH_DATA',         '%s');\n", $pathShared );

                $dbText .= sprintf( "  define('PATH_C',            '%s');\n", $pathShared . 'compiled/' );

                $dbText .= sprintf( "  define('HASH_INSTALLATION', '%s');\n", $h );

                $dbText .= sprintf( "  define('SYSTEM_HASH',       '%s');\n", $sh );

                $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array(FILE_PATHS_INSTALLED) ));

                file_put_contents( FILE_PATHS_INSTALLED, $dbText );

            }



            /**

             * AppCacheView Build

             */

            define( 'HASH_INSTALLATION', $h );

            define( 'SYSTEM_HASH', $sh );

            define( 'PATH_DB', $pathShared . 'sites' . PATH_SEP );

            define( 'SYS_SYS', $workspace );



            require_once ("propel/Propel.php");



            Propel::init( PATH_CORE . "config/databases.php" );

            $con = Propel::getConnection( 'workflow' );



            require_once ('classes/model/AppCacheView.php');

            $lang = 'en';



            //setup the appcacheview object, and the path for the sql files

            $appCache = new AppCacheView();



            $appCache->setPathToAppCacheFiles( PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP );



            //Update APP_DELEGATION.DEL_LAST_INDEX data

            $res = $appCache->updateAppDelegationDelLastIndex($lang, true);



            //APP_DELEGATION INSERT

            $res = $appCache->triggerAppDelegationInsert( $lang, true );



            //APP_DELEGATION Update

            $res = $appCache->triggerAppDelegationUpdate( $lang, true );



            //APPLICATION UPDATE

            $res = $appCache->triggerApplicationUpdate( $lang, true );



            //APPLICATION DELETE

            $res = $appCache->triggerApplicationDelete( $lang, true );



            //SUB_APPLICATION INSERT

            $res = $appCache->triggerSubApplicationInsert($lang, false);



            //CONTENT UPDATE

            $res = $appCache->triggerContentUpdate( $lang, true );



            //build using the method in AppCacheView Class

            $res = $appCache->fillAppCacheView( $lang );



            //end AppCacheView Build





            //erik: for new env conf handling

            G::loadClass( 'system' );

            $envFile = PATH_CONFIG . 'env.ini';



            // getting configuration from env.ini

            $sysConf = System::getSystemConfiguration( $envFile );



            $langUri = 'en';

            if (isset($sysConf['default_lang'])) {

                $langUri = $sysConf['default_lang'];

            }



            $skinUri = 'neoclassic';

            if (isset($sysConf['default_skin'])) {

                $skinUri = $sysConf['default_skin'];

            }



            $updatedConf['default_lang'] = $langUri;

            $updatedConf['default_skin'] = $skinUri;

            $info->uri =  PATH_SEP . 'sys' . $_REQUEST['workspace'] . PATH_SEP . $langUri . PATH_SEP . $skinUri . PATH_SEP . 'login' . PATH_SEP . 'login';



            //register PMDesigner Client

            $http = (G::is_https() == true) ? 'https' : 'http';

            $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');



            $endpoint = sprintf(

                '%s://%s/sys%s/%s/%s/oauth2/grant',

                $http,

                $host,

                $workspace,

                $langUri,

                $skinUri

            );



            // inserting the outh_client

            if (!$userLogged) {

                $query = sprintf( "USE %s;", $wf );

            } else {

                $query = sprintf( "USE %s;", trim( $_REQUEST['wfDatabase']) );

            }

            $this->mysqlQuery( $query );

            $query = ( "INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES

                ('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )");

            $this->mysqlQuery( $query );



            $indexFileUpdated = true;

            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $this->buildParternExtras($adminUsername, $adminPassword, $_REQUEST['workspace'], $langUri, $skinUri);

            } else {

                try {

                    G::update_php_ini( $envFile, $updatedConf );

                } catch (Exception $e) {

                    $info->result = false;

                    $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array($envFile));

                    $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL');

                    $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('env.ini')));

                    return $info;

                }



                try {

                    // update the main index file

                    $indexFileUpdated = System::updateIndexFile(array('lang' => 'en','skin' => $updatedConf['default_skin']));

                } catch (Exception $e) {

                    $info->result = false;

                    $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array(PATH_HTML . "index.html."));

                    $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL');

                    $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('index.html')));

                    return $info;

                }

            }



            $this->installLog( G::LoadTranslation('ID_INDEX_FILE_UPDATED', SYS_LANG, Array($indexFileUpdated, $sysConf['default_lang'],$sysConf['default_skin'])));

            $this->installLog( G::LoadTranslation('ID_INSTALL_SUCESS') );



            $info->result = true;

            $info->message = G::LoadTranslation('ID_INSTALL_SUCESS');

            $info->messageFinish = G::LoadTranslation('ID_PROCESSMAKER_SUCCESS_INSTALLED', SYS_LANG, Array($workspace));;

        } catch (Exception $e) {

            $info->canRedirect = false;

            $info->result = false;

            $info->message = $e->getMessage();

        }

        return $info;

    }
示例#4
0
 public static function browserCacheFilesSetUid()
 {
     //Set UID
     $uid = G::generateUniqueID();
     $arrayData = array();
     $arrayData["browser_cache_files_uid"] = $uid;
     G::update_php_ini(PATH_CONFIG . "env.ini", $arrayData);
     //Set file JavaScript
     $arrayLibrary = G::browserCacheFilesGetLibraryJs();
     foreach ($arrayLibrary as $index => $value) {
         $name = $index;
         $path = $value;
         if (!empty($path)) {
             foreach (glob($path . $name . "*") as $file) {
                 if (preg_match("/^\\.\\w{32}\\.js\$/i", str_replace($path . $name, null, $file))) {
                     @unlink($file);
                     //Delete old file
                 }
             }
             if (file_exists($path . $name . ".js")) {
                 @copy($path . $name . ".js", $path . $name . "." . $uid . ".js");
                 //Create new file
             }
         }
     }
 }
示例#5
0
 public function saveSystemConf($httpData)
 {
     G::loadClass('system');
     $envFile = PATH_CONFIG . 'env.ini';
     $updateRedirector = false;
     $restart = false;
     if (!file_exists($envFile)) {
         if (!is_writable(PATH_CONFIG)) {
             throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config');
         }
         $content = ";\r\n";
         $content .= "; ProcessMaker System Bootstrap Configuration\r\n";
         $content .= ";\r\n";
         file_put_contents($envFile, $content);
         //@chmod($envFile, 0777);
     } else {
         if (!is_writable($envFile)) {
             throw new Exception('The enviroment ini file file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini');
         }
     }
     $sysConf = System::getSystemConfiguration($envFile);
     $updatedConf = array();
     if ($sysConf['default_lang'] != $httpData->default_lang) {
         $updatedConf['default_lang'] = $sysConf['default_lang'] = $httpData->default_lang;
         $updateRedirector = true;
     }
     if ($sysConf['default_skin'] != $httpData->default_skin) {
         $updatedConf['default_skin'] = $sysConf['default_skin'] = $httpData->default_skin;
         $updateRedirector = true;
     }
     if ($sysConf['time_zone'] != $httpData->time_zone) {
         $updatedConf['time_zone'] = $httpData->time_zone;
     }
     $httpData->memory_limit .= 'M';
     if ($sysConf['memory_limit'] != $httpData->memory_limit) {
         $updatedConf['memory_limit'] = $httpData->memory_limit;
     }
     if ($sysConf['proxy_host'] != $httpData->proxy_host) {
         $updatedConf['proxy_host'] = $httpData->proxy_host;
     }
     if ($sysConf['proxy_port'] != $httpData->proxy_port) {
         $updatedConf['proxy_port'] = $httpData->proxy_port;
     }
     if ($sysConf['proxy_user'] != $httpData->proxy_user) {
         $updatedConf['proxy_user'] = $httpData->proxy_user;
     }
     if ($sysConf['proxy_pass'] != $httpData->proxy_pass) {
         $updatedConf['proxy_pass'] = G::encrypt($httpData->proxy_pass, 'proxy_pass');
     }
     $sessionGcMaxlifetime = ini_get('session.gc_maxlifetime');
     if ($httpData->max_life_time != "" && $sessionGcMaxlifetime != $httpData->max_life_time) {
         if (!isset($sysConf['session.gc_maxlifetime']) || $sysConf['session.gc_maxlifetime'] != $httpData->max_life_time) {
             $updatedConf['session.gc_maxlifetime'] = $httpData->max_life_time;
         }
     }
     if ($updateRedirector) {
         if (!file_exists(PATH_HTML . 'index.html')) {
             throw new Exception('The index.html file is not writable on workflow/public_html directory.');
         } else {
             if (!is_writable(PATH_HTML . 'index.html')) {
                 throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html');
             }
         }
         System::updateIndexFile(array('lang' => $sysConf['default_lang'], 'skin' => $sysConf['default_skin']));
         $restart = true;
     }
     G::update_php_ini($envFile, $updatedConf);
     if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
         $urlPart = '/main/login';
     } else {
         $urlPart = '/login/login';
     }
     $this->success = true;
     $this->restart = $restart;
     $this->url = "/sys" . SYS_SYS . "/" . ($sysConf["default_lang"] != "" ? $sysConf["default_lang"] : (defined("SYS_LANG") && SYS_LANG != "" ? SYS_LANG : "en")) . "/" . $sysConf["default_skin"] . $urlPart;
     $this->message = 'Saved Successfully';
     $msg = "";
     if ($httpData->proxy_host != '' || $httpData->proxy_port != '' || $httpData->proxy_user != '') {
         $msg = ", Host -> " . $httpData->proxy_host . ", Port -> " . $httpData->proxy_port . ", User -> " . $httpData->proxy_user;
     }
     G::auditLog("UploadSystemSettings", "Time Zone -> " . $httpData->time_zone . ", Memory Limit -> " . $httpData->memory_limit . ", Cookie lifetime -> " . $httpData->max_life_time . ", Default Skin -> " . $httpData->default_skin . ", Default Language -> " . $httpData->default_lang . $msg);
 }
示例#6
0
 public function createMySQLWorkspace()
 {
     ini_set('max_execution_time', '0');
     $info->result = false;
     $info->message = '';
     $info->canRedirect = true;
     $db_hostname = trim($_REQUEST['db_hostname']);
     $db_port = trim($_REQUEST['db_port']);
     $db_username = trim($_REQUEST['db_username']);
     $db_password = trim($_REQUEST['db_password']);
     $wf = trim($_REQUEST['wfDatabase']);
     $rb = trim($_REQUEST['rbDatabase']);
     $rp = trim($_REQUEST['rpDatabase']);
     $workspace = trim($_REQUEST['workspace']);
     $pathConfig = trim($_REQUEST['pathConfig']);
     $pathLanguages = trim($_REQUEST['pathLanguages']);
     $pathPlugins = trim($_REQUEST['pathPlugins']);
     $pathShared = trim($_REQUEST['pathShared']);
     $pathXmlforms = trim($_REQUEST['pathXmlforms']);
     $adminPassword = trim($_REQUEST['adminPassword']);
     $adminUsername = trim($_REQUEST['adminUsername']);
     $deleteDB = $_REQUEST['deleteDB'] == 'true';
     if (substr($pathShared, -1) != '/') {
         $pathShared .= '/';
     }
     $this->installLog('-------------------------------------------');
     $this->installLog(sprintf("Creating workspace '%s' ", $workspace));
     try {
         $db_host = $db_port != '' && $db_port != 3306 ? $db_hostname . ':' . $db_port : $db_hostname;
         $this->link = @mysql_connect($db_host, $db_username, $db_password);
         $this->installLog(sprintf("Connected to server %s:%d using user: '******' ", $db_hostname, $db_port, $db_username));
         if ($deleteDB) {
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $wf, $wf);
             $this->mysqlQuery($q);
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $rb, $rb);
             $this->mysqlQuery($q);
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $rp, $rp);
             $this->mysqlQuery($q);
         }
         // CREATE databases wf_workflow, rb_workflow and rp_workflow
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $wf, $wf);
         $this->mysqlQuery($q);
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $rb, $rb);
         $this->mysqlQuery($q);
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $rp, $rp);
         $this->mysqlQuery($q);
         // CREATE users and GRANT Privileges
         $wfPass = G::generate_password(12);
         $rbPass = G::generate_password(12);
         $rpPass = G::generate_password(12);
         $this->setGrantPrivilegesMySQL($wf, $wfPass, $wf, $db_hostname);
         $this->setGrantPrivilegesMySQL($rb, $rbPass, $rb, $db_hostname);
         $this->setGrantPrivilegesMySQL($rp, $rpPass, $rp, $db_hostname);
         // Generate the db.php file and folders
         $path_site = $pathShared . "/sites/" . $workspace . "/";
         $db_file = $path_site . "db.php";
         @mkdir($path_site, 0777, true);
         @mkdir($path_site . "files/", 0777, true);
         @mkdir($path_site . "mailTemplates/", 0777, true);
         @mkdir($path_site . "public/", 0777, true);
         @mkdir($path_site . "reports/", 0777, true);
         @mkdir($path_site . "xmlForms", 0777, true);
         $dbText = "<?php\n";
         $dbText .= sprintf("// Processmaker configuration\n");
         $dbText .= sprintf("  define ('DB_ADAPTER',     '%s' );\n", 'mysql');
         $dbText .= sprintf("  define ('DB_HOST',        '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_NAME',        '%s' );\n", $wf);
         $dbText .= sprintf("  define ('DB_USER',        '%s' );\n", $wf);
         $dbText .= sprintf("  define ('DB_PASS',        '%s' );\n", $wfPass);
         $dbText .= sprintf("  define ('DB_RBAC_HOST',   '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_RBAC_NAME',   '%s' );\n", $rb);
         $dbText .= sprintf("  define ('DB_RBAC_USER',   '%s' );\n", $rb);
         $dbText .= sprintf("  define ('DB_RBAC_PASS',   '%s' );\n", $rbPass);
         $dbText .= sprintf("  define ('DB_REPORT_HOST', '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_REPORT_NAME', '%s' );\n", $rp);
         $dbText .= sprintf("  define ('DB_REPORT_USER', '%s' );\n", $rp);
         $dbText .= sprintf("  define ('DB_REPORT_PASS', '%s' );\n", $rpPass);
         $this->installLog("Creating: " . $db_file);
         file_put_contents($db_file, $dbText);
         // Generate the databases.php file
         $databases_file = $path_site . 'databases.php';
         $dbData = sprintf("\$dbAdapter    = '%s';\n", 'mysql');
         $dbData .= sprintf("\$dbHost       = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbName       = '%s';\n", $wf);
         $dbData .= sprintf("\$dbUser       = '******';\n", $wf);
         $dbData .= sprintf("\$dbPass       = '******';\n", $wfPass);
         $dbData .= sprintf("\$dbRbacHost   = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbRbacName   = '%s';\n", $rb);
         $dbData .= sprintf("\$dbRbacUser   = '******';\n", $rb);
         $dbData .= sprintf("\$dbRbacPass   = '******';\n", $rbPass);
         $dbData .= sprintf("\$dbReportHost = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbReportName = '%s';\n", $rp);
         $dbData .= sprintf("\$dbReportUser = '******';\n", $rp);
         $dbData .= sprintf("\$dbReportPass = '******';\n", $rpPass);
         $databasesText = str_replace('{dbData}', $dbData, @file_get_contents(PATH_HOME . 'engine/templates/installer/databases.tpl'));
         $this->installLog('Creating: ' . $databases_file);
         file_put_contents($databases_file, $databasesText);
         // Execute scripts to create and populates databases
         $query = sprintf("USE %s;", $rb);
         $this->mysqlQuery($query);
         $this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/schema.sql');
         $this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/insert.sql');
         $query = sprintf("USE %s;", $wf);
         $this->mysqlQuery($query);
         $this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/schema.sql');
         $this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/insert.sql');
         // Create the triggers
         if (file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql')) {
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql'));
             $this->mysqlQuery("INSERT INTO `CONFIGURATION` (\n                            `CFG_UID`,\n                            `CFG_VALUE`\n                           )\n                           VALUES (\n                             'APP_CACHE_VIEW_ENGINE',\n                             '" . mysql_real_escape_string(serialize(array('LANG' => 'en', 'STATUS' => 'active'))) . "'\n                           )");
         }
         // Change admin user
         $query = sprintf("USE %s;", $wf);
         $this->mysqlQuery($query);
         $query = sprintf("UPDATE USERS SET USR_USERNAME = '******', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5($adminPassword));
         $this->mysqlQuery($query);
         $query = sprintf("USE %s;", $rb);
         $this->mysqlQuery($query);
         $query = sprintf("UPDATE USERS SET USR_USERNAME = '******', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5($adminPassword));
         $this->mysqlQuery($query);
         // Write the paths_installed.php file (contains all the information configured so far)
         if (!file_exists(FILE_PATHS_INSTALLED)) {
             $sh = md5(filemtime(PATH_GULLIVER . '/class.g.php'));
             $h = G::encrypt($db_hostname . $sh . $db_username . $sh . $db_password, $sh);
             $dbText = "<?php\n";
             $dbText .= sprintf("  define('PATH_DATA',         '%s');\n", $pathShared);
             $dbText .= sprintf("  define('PATH_C',            '%s');\n", $pathShared . 'compiled/');
             $dbText .= sprintf("  define('HASH_INSTALLATION', '%s');\n", $h);
             $dbText .= sprintf("  define('SYSTEM_HASH',       '%s');\n", $sh);
             $this->installLog("Creating: " . FILE_PATHS_INSTALLED);
             file_put_contents(FILE_PATHS_INSTALLED, $dbText);
         }
         /**
          * AppCacheView Build
          */
         define('HASH_INSTALLATION', $h);
         define('SYSTEM_HASH', $sh);
         define('PATH_DB', $pathShared . 'sites' . PATH_SEP);
         define('SYS_SYS', 'workflow');
         require_once "propel/Propel.php";
         Propel::init(PATH_CORE . "config/databases.php");
         $con = Propel::getConnection('workflow');
         require_once 'classes/model/AppCacheView.php';
         $lang = 'en';
         //setup the appcacheview object, and the path for the sql files
         $appCache = new AppCacheView();
         $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
         //APP_DELEGATION INSERT
         $res = $appCache->triggerAppDelegationInsert($lang, true);
         //APP_DELEGATION Update
         $res = $appCache->triggerAppDelegationUpdate($lang, true);
         //APPLICATION UPDATE
         $res = $appCache->triggerApplicationUpdate($lang, true);
         //APPLICATION DELETE
         $res = $appCache->triggerApplicationDelete($lang, true);
         //CONTENT UPDATE
         $res = $appCache->triggerContentUpdate($lang, true);
         //build using the method in AppCacheView Class
         $res = $appCache->fillAppCacheView($lang);
         //end AppCacheView Build
         //erik: for new env conf handling
         G::loadClass('system');
         $envFile = PATH_CONFIG . 'env.ini';
         //writting for new installtions to use the new skin 'uxmind' with new Front End ExtJs Based
         $updatedConf['default_skin'] = 'uxmodern';
         $info->uri = '/sys' . $_REQUEST['workspace'] . '/en/uxmodern/main/login';
         try {
             G::update_php_ini($envFile, $updatedConf);
         } catch (Exception $e) {
             $info->result = false;
             $info->message = "ProcessMaker couldn't write on configuration file: {$envFile}.<br/>";
             $info->message .= "The new ProcessMaker UI couldn't be applied on installation, you can enable it after from Admin->System settings.";
             $this->installLog("Installed but with error, couldn't update env.ini");
             return $info;
         }
         // getting configuration from env.ini
         $sysConf = System::getSystemConfiguration($envFile);
         try {
             // update the main index file
             $indexFileUpdated = System::updateIndexFile(array('lang' => 'en', 'skin' => $updatedConf['default_skin']));
         } catch (Exception $e) {
             $info->result = false;
             $info->message = "ProcessMaker couldn't write on configuration file: " . PATH_HTML . "index.html.<br/>";
             $info->message .= "The new ProcessMaker UI couldn't be applied on installation, you can enable it after from Admin->System settings.";
             $this->installLog("Installed but with error, couldn't update index.html");
             return $info;
         }
         $this->installLog("Index File updated {$indexFileUpdated} with lang: {$sysConf['default_lang']}, skin: {$sysConf['default_skin']} ");
         $this->installLog("Install completed Succesfully");
         $info->result = true;
         $info->message = 'Succesfully OK';
     } catch (Exception $e) {
         $info->canRedirect = false;
         $info->result = false;
         $info->message = $e->getMessage();
     }
     return $info;
 }