mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
changes rules for nginx server
This commit is contained in:
@@ -148,7 +148,7 @@ class Installer
|
||||
*/
|
||||
public function saveData($database, $language)
|
||||
{
|
||||
$initData = include('install/core/afterInstall/config.php');
|
||||
$initData = include('install/core/init/config.php');
|
||||
|
||||
$siteUrl = $this->getSystemHelper()->getBaseUrl();
|
||||
|
||||
@@ -194,7 +194,9 @@ class Installer
|
||||
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
|
||||
|
||||
$preferences['currencyList'] = array($preferences['defaultCurrency']);
|
||||
$preferences['baseCurrency'] = $preferences['defaultCurrency'];
|
||||
|
||||
$preferences['currency'] = $this->getConfig()->get('currency');
|
||||
$preferences['currency']['base'] = $preferences['defaultCurrency'];
|
||||
}
|
||||
|
||||
$res = $this->saveConfig($preferences);
|
||||
@@ -208,7 +210,7 @@ class Installer
|
||||
|
||||
protected function createRecords()
|
||||
{
|
||||
$records = include('install/core/afterInstall/records.php');
|
||||
$records = include('install/core/init/records.php');
|
||||
|
||||
$result = true;
|
||||
foreach ($records as $entityName => $recordList) {
|
||||
@@ -269,6 +271,8 @@ class Installer
|
||||
|
||||
$result = $this->createRecord('User', $user);
|
||||
|
||||
$result &= $this->createRecords();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -311,16 +315,9 @@ class Installer
|
||||
|
||||
public function setSuccess()
|
||||
{
|
||||
$this->auth();
|
||||
|
||||
/** afterInstall scripts */
|
||||
$result = $this->createRecords();
|
||||
$result &= $this->executeQueries();
|
||||
/** END: afterInstall scripts */
|
||||
|
||||
$config = $this->app->getContainer()->get('config');
|
||||
$config->set('isInstalled', true);
|
||||
$result &= $config->save();
|
||||
$result = $config->save();
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -382,21 +379,5 @@ class Installer
|
||||
return $this->getContainer()->get('scheduledJob')->getSetupMessage();
|
||||
}
|
||||
|
||||
protected function executeQueries()
|
||||
{
|
||||
$queries = include('install/core/afterInstall/queries.php');
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$result = true;
|
||||
|
||||
foreach ($queries as $query) {
|
||||
$sth = $pdo->prepare($query);
|
||||
$result =& $sth->execute();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
55
install/core/Language.php
Normal file
55
install/core/Language.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Language
|
||||
{
|
||||
private $defaultLanguage = 'en_US';
|
||||
|
||||
private $systemHelper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once 'SystemHelper.php';
|
||||
$this->systemHelper = new SystemHelper();
|
||||
}
|
||||
|
||||
protected function getSystemHelper()
|
||||
{
|
||||
return $this->systemHelper;
|
||||
}
|
||||
|
||||
public function get($language)
|
||||
{
|
||||
if (empty($language)) {
|
||||
$language = $this->defaultLanguage;
|
||||
}
|
||||
|
||||
$langFileName = 'install/core/i18n/'.$language.'/install.json';
|
||||
if (!file_exists($langFileName)) {
|
||||
$langFileName = 'install/core/i18n/'.$this->defaultLanguage.'/install.json';
|
||||
}
|
||||
|
||||
$i18n = file_get_contents($langFileName);
|
||||
$i18n = json_decode($i18n, true);
|
||||
|
||||
$this->afterRetrieve($i18n);
|
||||
|
||||
return $i18n;
|
||||
}
|
||||
|
||||
/**
|
||||
* After retrieve actions
|
||||
*
|
||||
* @param array $i18n
|
||||
* @return array $i18n
|
||||
*/
|
||||
protected function afterRetrieve(array &$i18n)
|
||||
{
|
||||
/** Get rewrite rules */
|
||||
$serverType = $this->getSystemHelper()->getServerType();
|
||||
$rewriteRules = $this->getSystemHelper()->getRewriteRules();
|
||||
$i18n['options']['modRewriteHelp'][$serverType] = str_replace('{0}', $rewriteRules, $i18n['options']['modRewriteHelp'][$serverType]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql', $isCreateDatabase = true)
|
||||
public function checkDbConnection($hostName, $port ,$dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql')
|
||||
{
|
||||
$result['success'] = true;
|
||||
|
||||
@@ -104,28 +104,6 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
$result['errors']['dbConnect']['errorMsg'] = $e->getMessage();
|
||||
$result['success'] = false;
|
||||
}
|
||||
|
||||
/** try to create a database */
|
||||
if ($isCreateDatabase && !$result['success'] && $result['errors']['dbConnect']['errorCode'] == '1049') {
|
||||
|
||||
$dsn = "mysql:host={$hostName};" . ((!empty($port)) ? "port={$port}" : '');
|
||||
$pdo = new PDO($dsn, $dbUserName, $dbUserPass);
|
||||
|
||||
$isCreated = true;
|
||||
try {
|
||||
$pdo->query("CREATE DATABASE IF NOT EXISTS `$dbName`");
|
||||
} catch (PDOException $e) {
|
||||
$isCreated = false;
|
||||
}
|
||||
|
||||
if ($isCreated) {
|
||||
return $this->checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver, false);
|
||||
}
|
||||
}
|
||||
/** END: try to create a database */
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -207,8 +185,8 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
$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)';
|
||||
$commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +';
|
||||
$commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +';
|
||||
|
||||
if (count($permissions) >= 2) {
|
||||
return implode(' ' . $this->combineOperator . ' ', $commands);
|
||||
@@ -273,4 +251,19 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $cd;
|
||||
}
|
||||
|
||||
public function getRewriteRules()
|
||||
{
|
||||
$serverType = $this->getServerType();
|
||||
|
||||
$rules = array(
|
||||
'nginx' => "location /api/v1/ {\n if (!-e " . '$request_filename' . "){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}\n\nlocation /(data|api) {\n if (-e " . '$request_filename' . "){\n return 403;\n }\n}\n\nlocation /data/logs {\n return 403;\n}\nlocation /data/config.php$ {\n return 403;\n}\nlocation /data/cache {\n return 403;\n}\nlocation /data/upload {\n return 403;\n}\nlocation /application {\n return 403;\n}\nlocation /custom {\n return 403;\n}\nlocation /vendor {\n return 403;\n}",
|
||||
);
|
||||
|
||||
if (isset($rules[$serverType])) {
|
||||
return $rules[$serverType];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Fehler: EspoCRM API nicht verfügbar<br>Mögliches Problem: deaktiviertes \"mod_rewrite\" des Apache Servers oder des .htaccess Supports.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Fehler: EspoCRM API nicht verfügbar<br>Mögliches Problem: deaktiviertes \"URL Rewrite\". Bitte überprüfen und aktivieren Sie das \"URL Rewrite\" Modul im IIS Server.",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API unavailable.<br> Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API unavailable.<br> Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API unavailable.<br> Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API niet beschikbaar.<br> Mogelijke Oorzaak: disabled \"mod_rewrite\" in Apache server of .htaccess ondersteuning.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API niet beschikbaar.<br> Mogelijk probleem: disabled \"URL Rewrite\". Controleer en activeer \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "Eroare API: API-ul EspoCRM nu este valabil.<br> Probleme posibile: este dezactivat \"mod_rewrite\" in server-ul Apache, sau in .htaccess.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "Eroare API: API-ul EspoCRM nu este valabil.<br> Probleme posibile: este dezactivat \"URL Rewrite\". Verificati si activati modulul \"URL Rewrite\" in server-ul IIS",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API unavailable.<br> Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation \/api\/v1\/ {\n if (!-e $request_filename){\n rewrite ^\/api\/v1\/(.*)$ \/api\/v1\/index.php last; break;\n }\n}\n\nlocation \/ {\n rewrite reset\/?$ reset.html break;\n}<\/pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
"modRewriteHelp": {
|
||||
"apache": "API Error: EspoCRM API unavailable.<br> Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to Nginx Host Config (inside \"server\" block):<br>\n<pre>\nlocation /api/v1/ {\n if (!-e $request_filename){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}</pre>",
|
||||
"nginx": "API Error: EspoCRM API unavailable.<br> Add this code to your Nginx Host Config (inside \"server\" block):<br>\n<pre>\n{0}\n</pre>",
|
||||
"microsoft-iis": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server",
|
||||
"default": "API Error: EspoCRM API unavailable.<br> Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support."
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<h4 class="panel-title">{$langs['labels']['Step2 page title']}</h4>
|
||||
</header>
|
||||
<div class="panel-body body">
|
||||
|
||||
|
||||
<div id="msg-box" class="alert hide"></div>
|
||||
<div class="loading-icon hide"></div>
|
||||
|
||||
<form id="nav">
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
@@ -45,14 +45,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<div class="loading-icon hide"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<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>
|
||||
@@ -60,8 +61,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="modal-footer">
|
||||
<button class="btn btn-default" type="button" id="back">{$langs['labels']['Back']}</button>
|
||||
<button class="btn btn-primary" type="button" id="next">{$langs['labels']['Next']}</button>
|
||||
|
||||
@@ -37,14 +37,11 @@ if (!empty($_REQUEST)) {
|
||||
|
||||
// get user selected language
|
||||
$userLang = (!empty($_SESSION['install']['user-lang']))? $_SESSION['install']['user-lang'] : 'en_US';
|
||||
$langFileName = 'core/i18n/'.$userLang.'/install.json';
|
||||
$langs = array();
|
||||
if (file_exists('install/'.$langFileName)) {
|
||||
$langs = file_get_contents('install/'.$langFileName);
|
||||
} else {
|
||||
$langs = file_get_contents('install/core/i18n/en_US/install.json');
|
||||
}
|
||||
$langs = json_decode($langs, true);
|
||||
|
||||
require_once 'core/language.php';
|
||||
$language = new Language();
|
||||
$langs = $language->get($userLang);
|
||||
//END: get user selected language
|
||||
|
||||
require_once 'core/SystemHelper.php';
|
||||
$systemHelper = new SystemHelper();
|
||||
|
||||
Reference in New Issue
Block a user