installer: design changes
This commit is contained in:
@@ -76,13 +76,13 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function checkDbConnection($hostName, $dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql')
|
||||
public function checkDbConnection($hostName, $port ,$dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql')
|
||||
{
|
||||
$result['success'] = true;
|
||||
|
||||
switch ($dbDriver) {
|
||||
case 'mysqli':
|
||||
$mysqli = new mysqli($hostName, $dbUserName, $dbUserPass, $dbName);
|
||||
$mysqli = (empty($port)) ? new mysqli($hostName, $dbUserName, $dbUserPass, $dbName) : new mysqli($hostName, $dbUserName, $dbUserPass, $dbName, $port);
|
||||
if (!$mysqli->connect_errno) {
|
||||
$mysqli->close();
|
||||
}
|
||||
@@ -95,7 +95,8 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
|
||||
case 'pdo_mysql':
|
||||
try {
|
||||
$dbh = new PDO("mysql:host={$hostName};dbname={$dbName}", $dbUserName, $dbUserPass);
|
||||
$dsn = "mysql:host={$hostName};" . ((!empty($port)) ? "port={$port};" : '') . "dbname={$dbName}";
|
||||
$dbh = new PDO($dsn, $dbUserName, $dbUserPass);
|
||||
$dbh = null;
|
||||
} catch (PDOException $e) {
|
||||
|
||||
@@ -129,48 +130,9 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $this->modRewriteUrl;
|
||||
}
|
||||
|
||||
public function getChmodCommand($path, $permissions = array('755'), $isSudo = false, $isFile = null, $isCd = true)
|
||||
{
|
||||
//$path = $this->getFullPath($path);
|
||||
|
||||
$path = empty($path) ? '*' : $path;
|
||||
if (is_array($path)) {
|
||||
$path = implode(' ', $path);
|
||||
}
|
||||
|
||||
$sudoStr = $isSudo ? 'sudo ' : '';
|
||||
|
||||
$cd = $isCd ? $this->getCd(true) : '';
|
||||
|
||||
if (is_string($permissions)) {
|
||||
$permissions = (array) $permissions;
|
||||
}
|
||||
|
||||
if (!isset($isFile) && count($permissions) == 1) {
|
||||
return $cd.$sudoStr.'chmod -R '.$permissions[0].' '.$path;
|
||||
}
|
||||
|
||||
$bufPerm = (count($permissions) == 1) ? array_fill(0, 2, $permissions[0]) : $permissions;
|
||||
|
||||
$commands = array();
|
||||
|
||||
if ($isCd) {
|
||||
$commands[] = $this->getCd();
|
||||
}
|
||||
|
||||
$commands[] = $sudoStr.'chmod '.$bufPerm[0].' $(find '.$path.' -type f)';
|
||||
$commands[] = $sudoStr.'chmod '.$bufPerm[1].' $(find '.$path.' -type d)';
|
||||
|
||||
if (count($permissions) >= 2) {
|
||||
return implode(' ' . $this->combineOperator . ' ', $commands);
|
||||
}
|
||||
|
||||
return $isFile ? $commands[0] : $commands[1];
|
||||
}
|
||||
|
||||
public function getChownCommand($path, $isSudo = false, $isCd = true)
|
||||
{
|
||||
$path = empty($path) ? '*' : $path;
|
||||
$path = empty($path) ? '.' : $path;
|
||||
if (is_array($path)) {
|
||||
$path = implode(' ', $path);
|
||||
}
|
||||
@@ -193,6 +155,46 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $cd.$sudoStr.'chown -R '.$owner.':'.$group.' '.$path;
|
||||
}
|
||||
|
||||
|
||||
public function getChmodCommand($path, $permissions = array('755'), $isSudo = false, $isFile = null, $isCd = true)
|
||||
{
|
||||
//$path = $this->getFullPath($path);
|
||||
|
||||
$path = empty($path) ? '.' : $path;
|
||||
if (is_array($path)) {
|
||||
$path = implode(' ', $path);
|
||||
}
|
||||
|
||||
$sudoStr = $isSudo ? 'sudo ' : '';
|
||||
|
||||
$cd = $isCd ? $this->getCd(true) : '';
|
||||
|
||||
if (is_string($permissions)) {
|
||||
$permissions = (array) $permissions;
|
||||
}
|
||||
|
||||
if (!isset($isFile) && count($permissions) == 1) {
|
||||
return $cd.'find '.$path.' -type d -exec ' . $sudoStr . 'chmod '.$permissions[0].' {} +';
|
||||
}
|
||||
|
||||
$bufPerm = (count($permissions) == 1) ? array_fill(0, 2, $permissions[0]) : $permissions;
|
||||
|
||||
$commands = array();
|
||||
|
||||
if ($isCd) {
|
||||
$commands[] = $this->getCd();
|
||||
}
|
||||
|
||||
$commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +';//.'chmod '.$bufPerm[0].' $(find '.$path.' -type f)';
|
||||
$commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +';//.'chmod '.$bufPerm[1].' $(find '.$path.' -type d)';
|
||||
|
||||
if (count($permissions) >= 2) {
|
||||
return implode(' ' . $this->combineOperator . ' ', $commands);
|
||||
}
|
||||
|
||||
return $isFile ? $commands[0] : $commands[1];
|
||||
}
|
||||
|
||||
public function getFullPath($path)
|
||||
{
|
||||
if (is_array($path)) {
|
||||
@@ -219,7 +221,7 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
* @param bool $isFile
|
||||
* @return string
|
||||
*/
|
||||
public function getPermissionCommands($path, $permissions = array('644', '755'), $isSudo = false, $isFile = null)
|
||||
public function getPermissionCommands($path, $permissions = array('644', '755'), $isSudo = false, $isFile = null, $changeOwner = true)
|
||||
{
|
||||
if (is_string($path)) {
|
||||
$path = array_fill(0, 2, $path);
|
||||
@@ -229,11 +231,12 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
$commands = array();
|
||||
$commands[] = $this->getChmodCommand($chmodPath, $permissions, $isSudo, $isFile);
|
||||
|
||||
$chown = $this->getChownCommand($chownPath, $isSudo, false);
|
||||
if (isset($chown)) {
|
||||
$commands[] = $chown;
|
||||
if ($changeOwner) {
|
||||
$chown = $this->getChownCommand($chownPath, $isSudo, false);
|
||||
if (isset($chown)) {
|
||||
$commands[] = $chown;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(' ' . $this->combineOperator . ' ', $commands).';';
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,16 @@ $result = array('success' => true, 'errorMsg' => '');
|
||||
// save settings
|
||||
$data = array(
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => $_SESSION['install']['host-name'],
|
||||
'port' => $_SESSION['install']['port'],
|
||||
'dbname' => $_SESSION['install']['db-name'],
|
||||
'user' => $_SESSION['install']['db-user-name'],
|
||||
'password' => $_SESSION['install']['db-user-password'],
|
||||
);
|
||||
$host = $_SESSION['install']['host-name'];
|
||||
if (strpos($host,':') === false) {
|
||||
$host .= ":";
|
||||
}
|
||||
list($data['host'], $data['port']) = explode(':', $host);
|
||||
|
||||
$lang = (!empty($_SESSION['install']['user-lang']))? $_SESSION['install']['user-lang'] : 'en_US';
|
||||
if (!$installer->saveData($data, $lang)) {
|
||||
$result['success'] = false;
|
||||
@@ -39,4 +43,4 @@ if (!$installer->saveData($data, $lang)) {
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
echo json_encode($result);
|
||||
echo json_encode($result);
|
||||
|
||||
@@ -31,11 +31,17 @@ if (!$installer->checkPermission()) {
|
||||
foreach($error as $folder => $permission) {
|
||||
$group[implode('-', $permission)][] = $folder;
|
||||
}
|
||||
ksort($group);
|
||||
$instruction = '';
|
||||
$instructionSU = '';
|
||||
$changeOwner = true;
|
||||
foreach($group as $permission => $folders) {
|
||||
$instruction .= $systemHelper->getPermissionCommands(array($folders, ''), explode('-', $permission)) . "<br>";
|
||||
$instructionSU .= " " . $systemHelper->getPermissionCommands(array($folders, ''), explode('-', $permission), true) . "<br>";
|
||||
if ($permission == '0644-0755') $folders = '';
|
||||
$instruction .= $systemHelper->getPermissionCommands(array($folders, ''), explode('-', $permission), false, null, $changeOwner) . "<br>";
|
||||
$instructionSU .= " " . $systemHelper->getPermissionCommands(array($folders, ''), explode('-', $permission), true, null, $changeOwner) . "<br>";
|
||||
if ($changeOwner) {
|
||||
$changeOwner = false;
|
||||
}
|
||||
}
|
||||
$result['errorMsg'] = $langs['messages']['Permission denied to'] . ':<br><pre>/'.implode('<br>/', $urls).'</pre>';
|
||||
$result['errorFixInstruction'] = str_replace( '"{C}"' , $instruction, $langs['messages']['permissionInstruction']) . "<br>" .
|
||||
|
||||
@@ -34,12 +34,15 @@ if (!empty($_REQUEST['dbName']) && !empty($_REQUEST['hostName']) && !empty($_REQ
|
||||
$connect = false;
|
||||
|
||||
$dbName = trim($_REQUEST['dbName']);
|
||||
$hostName = trim($_REQUEST['hostName']);
|
||||
if (strpos($_REQUEST['hostName'],':') === false) {
|
||||
$_REQUEST['hostName'] .= ":";
|
||||
}
|
||||
list($hostName, $port) = explode(':', trim($_REQUEST['hostName']));
|
||||
$dbUserName = trim($_REQUEST['dbUserName']);
|
||||
$dbUserPass = trim($_REQUEST['dbUserPass']);
|
||||
$dbDriver = (!empty($_REQUEST['dbDriver']))? $_REQUEST['dbDriver'] : 'pdo_mysql';
|
||||
|
||||
$res = $systemHelper->checkDbConnection($hostName, $dbUserName, $dbUserPass, $dbName, $dbDriver);
|
||||
$res = $systemHelper->checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver);
|
||||
$result['success'] &= $res['success'];
|
||||
if (!empty($res['errors'])) {
|
||||
$result['errors'] = array_merge($result['errors'], $res['errors']);
|
||||
@@ -48,4 +51,4 @@ if (!empty($_REQUEST['dbName']) && !empty($_REQUEST['hostName']) && !empty($_REQ
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
echo json_encode($result);
|
||||
echo json_encode($result);
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"Next": "Next",
|
||||
"Go to EspoCRM": "Go to EspoCRM",
|
||||
"Re-check": "Re-check",
|
||||
"Test settings": "Test Connection"
|
||||
"Test settings": "Test Connection",
|
||||
"Database Settings Description": "Enter your MySQL database connection information (hostname, username and password). You can specify the server port for hostname like localhost:3306."
|
||||
},
|
||||
"fields": {
|
||||
"Choose your language:": "Choose your language:",
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"Next": "Next",
|
||||
"Go to EspoCRM": "Go to EspoCRM",
|
||||
"Re-check": "Re-check",
|
||||
"Test settings": "Test Connection"
|
||||
"Test settings": "Test Connection",
|
||||
"Database Settings Description": "Enter your MySQL database connection information (hostname, username and password). You can specify the server port for hostname like localhost:3306."
|
||||
},
|
||||
"fields": {
|
||||
"Choose your language:": "Choose your language:",
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
"Next": "Siguiente",
|
||||
"Go to EspoCRM": "Ir a EspoCRM(Español)",
|
||||
"Re-check": "Revisar otra vez",
|
||||
"Test settings": "Test de conexión"
|
||||
"Test settings": "Test de conexión",
|
||||
"Database Settings Description": "Enter your MySQL database connection information (hostname, username and password). You can specify the server port for hostname like localhost:3306."
|
||||
},
|
||||
"fields": {
|
||||
"Choose your language:": "Seleccione un lenguaje:",
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="modal-footer">
|
||||
<div class="cell cell-website pull-left" align="left">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Choose your language:']}</label>
|
||||
<div class="field field-website">
|
||||
@@ -30,6 +28,9 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="modal-footer">
|
||||
|
||||
<button class="btn btn-primary" type="button" id="start">{$langs['labels']['Start']}</button>
|
||||
</footer>
|
||||
</form>
|
||||
@@ -43,3 +44,4 @@
|
||||
})
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
|
||||
+24
-37
@@ -10,55 +10,23 @@
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<div class="host-name-c cell">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Host Name']} *</label>
|
||||
<div class="field field-website">
|
||||
<input type="text" value="{$fields['host-name'].value}" name="host-name" class="main-element form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="semicolon-sign-c cell">
|
||||
<label class="field-label-website control-label"> </label>
|
||||
<div class="semicolon-sign">:</div>
|
||||
</div>
|
||||
<div class="port-c cell">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Port']}</label>
|
||||
<div class="field field-website">
|
||||
<input type="text" value="{$fields['port'].value}" name="port" class="main-element form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Database Name']} *</label>
|
||||
<div class="field field-website">
|
||||
<input type="text" value="{$fields['db-name'].value}" name="db-name" class="main-element form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Database User Name']} *</label>
|
||||
<div class="field field-website">
|
||||
<input type="text" value="{$fields['db-user-name'].value}" name="db-user-name" class="main-element form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Database User Password']}</label>
|
||||
<div class="field field-website">
|
||||
@@ -67,12 +35,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<div class="label-description">
|
||||
{$langs['labels']['Database Settings Description']}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<div class="btn-panel">
|
||||
<button class="btn btn-default" type="button" id="test-connection">{$langs['labels']['Test settings']}</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<div class="btn-panel">
|
||||
<button class="btn btn-default" type="button" id="test-connection">{$langs['labels']['Test settings']}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="modal-footer">
|
||||
@@ -88,4 +75,4 @@
|
||||
var installScript = new InstallScript({action: 'step2', langs: langs});
|
||||
})
|
||||
{/literal}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -56,6 +56,13 @@ select[name="user-lang"] {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.label-description {
|
||||
line-height: 24px;
|
||||
height: 33px;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
padding: 14px 0 5px;
|
||||
}
|
||||
.semicolon-sign-c {
|
||||
text-align: center;
|
||||
width: 4%;
|
||||
|
||||
Reference in New Issue
Block a user