function SUGAR_INSTALL($servername, $root, $hash = array()) { $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log"; if ($root == null) { events("Starting install Sugar Unable to stat root dir"); return false; } $user = $hash["wwwmysqluser"][0]; $mysql_password = $hash[strtolower("WWWMysqlPassword")][0]; $appli_user = $hash["wwwappliuser"][0]; $appli_password = $hash["wwwapplipassword"][0]; $wwwsslmode = $hash["wwwsslmode"][0]; if ($wwwsslmode == "TRUE") { $SSL = true; } else { $SSL = false; } if ($user == null) { events("Starting install SugarCRM Unable to stat Mysql username"); return false; } if ($mysql_password == null) { events("Starting install SugarCRM Unable to stat Mysql password"); return false; } @mkdir($root, 0755, true); $server_database = str_replace(".", "_", $servername); $server_database = str_replace("-", "_", $server_database); $q = new mysql(); if (!$q->DATABASE_EXISTS($server_database)) { events("Install SugarCRM sub-system mysql database {$server_database}..."); $q->CREATE_DATABASE($server_database); } if (!$q->DATABASE_EXISTS($server_database)) { events("Install SugarCRM unable to create MYSQL Database"); return false; } if (!is_file("{$root}/index.php")) { events("Install SugarCRM installing source code"); shell_exec("/bin/cp -rf /usr/local/share/artica/sugarcrm_src/* {$root}/"); } if (!is_file("{$root}/install/siteConfig_a.php")) { events("Install SugarCRM installing install directory"); shell_exec("/bin/cp -rf /usr/local/share/artica/sugarcrm_src/install {$root}/"); } $sugar = new SugarCRM(); $sugar->sql_host = $q->mysql_server; $sugar->sql_db = $server_database; $sugar->sql_admin = $user; $sugar->sql_password = $mysql_password; if ($appli_user == null) { $appli_user = "******"; } $sugar->manager_name = $appli_user; $sugar->manager_password = $appli_password; $sugar->sugar_supposed_version = SUGAR_CRMVERSION($root); events("{$servername} v.{$sugar->sugar_supposed_version}"); $sugar->servername = $servername; $q->PRIVILEGES($user, $mysql_password, $server_database); $conf = $sugar->BuildSugarConf($SSL); events("Creating configuration file config.php"); @file_put_contents("{$root}/config.php", $conf); $conf_silent = $sugar->BuildSilentInstallConf($SSL); events("Creating silent configuration file config_si.php"); @file_put_contents("{$root}/config_si.php", $conf_silent); shell_exec("chmod -R 755 {$root}/include/javascript"); }
function SUGAR_INSTALL($servername, $root, $hash = array()) { $GLOBALS["ADDLOG"] = "/var/log/artica-postfix/{$servername}.log"; if ($root == null) { events("Starting install Sugar Unable to stat root dir"); return false; } $sql_file = "/usr/share/artica-postfix/bin/install/SugarCRM/sugarcrm.sql"; $user = $hash["wwwmysqluser"][0]; $mysql_password = $hash[strtolower("WWWMysqlPassword")][0]; $appli_user = $hash["wwwappliuser"][0]; $appli_password = $hash["wwwapplipassword"][0]; $wwwsslmode = $hash["wwwsslmode"][0]; if ($wwwsslmode == "TRUE") { $SSL = true; } else { $SSL = false; } if ($user == null) { events("Starting install SugarCRM Unable to stat Mysql username"); return false; } if ($mysql_password == null) { events("Starting install SugarCRM Unable to stat Mysql password"); return false; } @mkdir($root, 0755, true); $server_database = str_replace(".", "_", $servername); $server_database = str_replace("-", "_", $server_database); $q = new mysql(); if (!$q->DATABASE_EXISTS($server_database)) { events("Install SugarCRM sub-system mysql database {$server_database}..."); $q->CREATE_DATABASE($server_database); } if (!$q->DATABASE_EXISTS($server_database)) { events("Install SugarCRM unable to create MYSQL Database"); return false; } if (!is_file("{$root}/index.php")) { events("Install SugarCRM installing source code"); shell_exec("/bin/cp -rf /usr/local/share/artica/sugarcrm_src/* {$root}/"); } $sugar = new SugarCRM(); $manquesfichiers = $sugar->checkRootFiles($root); if (count($manquesfichiers) > 0) { events("Install SugarCRM installing source code missing " . count($manquesfichiers) . " files"); shell_exec("/bin/cp -rf /usr/local/share/artica/sugarcrm_src/* {$root}/"); } $sugar->sql_db = $server_database; $sugar->sql_admin = $user; $sugar->sql_password = $mysql_password; $sugar->sugar_supposed_version = SUGAR_CRMVERSION($root); events("{$servername} v.{$sugar->sugar_supposed_version}"); $sugar->servername = $servername; AddPrivileges($user, $mysql_password, $server_database); if (!$sugar->TestTables()) { if ($q->mysql_password != null) { $password = "******"; } else { events("Install SugarCRM installing tables datas with null password"); } $cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml "; $cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$sql_file}"; shell_exec($cmd); } if ($appli_user == null) { $appli_user = "******"; } $sugar->CreateAdminPassword($appli_user, $appli_password); $conf = $sugar->BuildSugarConf($SSL); events("Creating configuration file config.php"); @file_put_contents("{$root}/config.php", $conf); events("sugar version is {$sugar->sugar_supposed_version}"); $sql = "UPDATE `{$server_database}`.`config` SET `value` = '{$sugar->sugar_supposed_version}' \n\tWHERE `config`.`category` = 'info' \n\tAND `config`.`name` = 'sugar_version' LIMIT 1 ;"; $q = new mysql(); $q->QUERY_SQL($sql, $server_database); if (!$q->ok) { events("{$q->mysql_error}"); events("{$sql}"); } shell_exec("chmod -R 755 {$root}/include/javascript"); }