PMCORE-631
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\src\ProcessMaker\Util\Helpers;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class GetMysqlVersionTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test get the mysql version
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_get_mysql_version()
|
||||||
|
{
|
||||||
|
$this->assertNotEmpty(getMysqlVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ include PATH_LANGUAGECONT . "translation." . SYS_LANG;
|
|||||||
|
|
||||||
class InstallerModule extends Controller
|
class InstallerModule extends Controller
|
||||||
{
|
{
|
||||||
|
const MYSQL_VERSION_MAXIMUM_SUPPORTED = "5.7";
|
||||||
const PHP_VERSION_MINIMUM_SUPPORTED = "7.1";
|
const PHP_VERSION_MINIMUM_SUPPORTED = "7.1";
|
||||||
const PHP_VERSION_NOT_SUPPORTED = "7.4";
|
const PHP_VERSION_NOT_SUPPORTED = "7.4";
|
||||||
public $path_config;
|
public $path_config;
|
||||||
|
|||||||
@@ -1,107 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Processmaker\Core\System;
|
||||||
|
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
$_POST = $filter->xssFilterHard($_POST);
|
$_POST = $filter->xssFilterHard($_POST);
|
||||||
$_GET = $filter->xssFilterHard($_GET);
|
$_GET = $filter->xssFilterHard($_GET);
|
||||||
$request = isset($_POST['request']) ? $_POST['request'] : (isset($_GET['request']) ? $_GET['request'] : null);
|
$request = isset($_POST['request']) ? $_POST['request'] : (isset($_GET['request']) ? $_GET['request'] : null);
|
||||||
|
|
||||||
function testConnection($type, $server, $user, $passwd, $port = 'none', $dbName = "")
|
|
||||||
{
|
|
||||||
if (($port == 'none') || ($port == '') || ($port == 0)) {
|
|
||||||
//setting defaults ports
|
|
||||||
switch ($type) {
|
|
||||||
case 'mysql':
|
|
||||||
$port = 3306;
|
|
||||||
break;
|
|
||||||
case 'pgsql':
|
|
||||||
$port = 5432;
|
|
||||||
break;
|
|
||||||
case 'mssql':
|
|
||||||
$port = 1433;
|
|
||||||
break;
|
|
||||||
case 'oracle':
|
|
||||||
$port = 1521;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$Server = new Net($server);
|
|
||||||
$filter = new InputFilter();
|
|
||||||
|
|
||||||
if ($Server->getErrno() == 0) {
|
|
||||||
$Server->scannPort($port);
|
|
||||||
if ($Server->getErrno() == 0) {
|
|
||||||
$Server->loginDbServer($user, $passwd);
|
|
||||||
$Server->setDataBase($dbName, $port);
|
|
||||||
if ($Server->errno == 0) {
|
|
||||||
$response = $Server->tryConnectServer($type);
|
|
||||||
if ($response->status == 'SUCCESS') {
|
|
||||||
if ($Server->errno == 0) {
|
|
||||||
$message = "";
|
|
||||||
$response = $Server->tryConnectServer($type);
|
|
||||||
$server = $filter->validateInput($server);
|
|
||||||
$user = $filter->validateInput($user);
|
|
||||||
$passwd = $filter->validateInput($passwd);
|
|
||||||
$connDatabase = mysqli_connect($server, $user, $passwd);
|
|
||||||
$dbNameTest = "PROCESSMAKERTESTDC";
|
|
||||||
$dbNameTest = $filter->validateInput($dbNameTest, 'nosql');
|
|
||||||
$query = "CREATE DATABASE %s";
|
|
||||||
$query = $filter->preventSqlInjection($query, array($dbNameTest), $connDatabase);
|
|
||||||
$db = mysqli_query($connDatabase, $query);
|
|
||||||
$success = false;
|
|
||||||
if (!$db) {
|
|
||||||
$message = mysqli_error($connDatabase);
|
|
||||||
} else {
|
|
||||||
$usrTest = "wfrbtest";
|
|
||||||
$chkG = "GRANT ALL PRIVILEGES ON `%s`.* TO %s@'%%' IDENTIFIED BY 'sample' WITH GRANT OPTION";
|
|
||||||
$chkG = $filter->preventSqlInjection($chkG, array($dbNameTest, $usrTest), $connDatabase);
|
|
||||||
$ch = mysqli_query($connDatabase, $chkG);
|
|
||||||
if (!$ch) {
|
|
||||||
$message = mysqli_error($connDatabase);
|
|
||||||
} else {
|
|
||||||
$sqlCreateUser = "CREATE USER '%s'@'%%' IDENTIFIED BY '%s'";
|
|
||||||
$user = $filter->validateInput($user, 'nosql');
|
|
||||||
$sqlCreateUser = $filter->preventSqlInjection($sqlCreateUser, array($user . "_usertest", "sample"), $connDatabase);
|
|
||||||
$result = mysqli_query($connDatabase, $sqlCreateUser);
|
|
||||||
if (!$result) {
|
|
||||||
$message = mysqli_error($connDatabase);
|
|
||||||
} else {
|
|
||||||
$success = true;
|
|
||||||
$message = G::LoadTranslation('ID_SUCCESSFUL_CONNECTION');
|
|
||||||
}
|
|
||||||
$sqlDropUser = "DROP USER '%s'@'%%'";
|
|
||||||
$user = $filter->validateInput($user, 'nosql');
|
|
||||||
$sqlDropUser = $filter->preventSqlInjection($sqlDropUser, array($user . "_usertest"), $connDatabase);
|
|
||||||
mysqli_query($connDatabase, $sqlDropUser);
|
|
||||||
|
|
||||||
$sqlDropUser = "DROP USER %s@'%%'";
|
|
||||||
$usrTest = $filter->validateInput($usrTest, 'nosql');
|
|
||||||
$sqlDropUser = $filter->preventSqlInjection($sqlDropUser, array($usrTest), $connDatabase);
|
|
||||||
mysqli_query($connDatabase, $sqlDropUser);
|
|
||||||
}
|
|
||||||
$sqlDropDb = "DROP DATABASE %s";
|
|
||||||
$dbNameTest = $filter->validateInput($dbNameTest, 'nosql');
|
|
||||||
$sqlDropDb = $filter->preventSqlInjection($sqlDropDb, array($dbNameTest), $connDatabase);
|
|
||||||
mysqli_query($connDatabase, $sqlDropDb);
|
|
||||||
}
|
|
||||||
return array($success, ($message != "") ? $message : $Server->error);
|
|
||||||
} else {
|
|
||||||
return array(false, $Server->error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return array(false, $Server->error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return array(false, $Server->error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return array(false, $Server->error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return array(false, $Server->error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($request) {
|
switch ($request) {
|
||||||
//check if the APP_CACHE VIEW table and their triggers are installed
|
//check if the APP_CACHE VIEW table and their triggers are installed
|
||||||
case 'info':
|
case 'info':
|
||||||
@@ -271,46 +176,25 @@ switch ($request) {
|
|||||||
break;
|
break;
|
||||||
case 'recreate-root':
|
case 'recreate-root':
|
||||||
$user = $_POST['user'];
|
$user = $_POST['user'];
|
||||||
$passwd = $_POST['password'];
|
$pass = $_POST['password'];
|
||||||
$server = $_POST['host'];
|
$server = $_POST['host'];
|
||||||
$code = $_POST['codeCaptcha'];
|
$code = $_POST['codeCaptcha'];
|
||||||
$aServer = explode(':', $server);
|
$server = explode(':', $server);
|
||||||
$serverName = $aServer[0];
|
$serverName = $server[0];
|
||||||
$port = (count($aServer) > 1) ? $aServer[1] : "none";
|
$port = (count($server) > 1) ? $server[1] : '';
|
||||||
|
|
||||||
if ($code !== $_SESSION['securimage_code_disp']['default']) {
|
if ($code !== $_SESSION['securimage_code_disp']['default']) {
|
||||||
echo G::loadTranslation('ID_CAPTCHA_CODE_INCORRECT');
|
echo G::loadTranslation('ID_CAPTCHA_CODE_INCORRECT');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
list($success, $message) = System::checkPermissionsDbUser(DB_ADAPTER, $serverName, $port, $user, $pass);
|
||||||
list($sucess, $msgErr) = testConnection(DB_ADAPTER, $serverName, $user, $passwd, $port);
|
if ($success) {
|
||||||
|
$id = 'ID_MESSAGE_ROOT_CHANGE_FAILURE';
|
||||||
if ($sucess) {
|
if (System::regenerateCredentiaslPathInstalled($server, $user, $pass)) {
|
||||||
$sh = G::encryptOld(filemtime(PATH_GULLIVER . "/class.g.php"));
|
$id = 'ID_MESSAGE_ROOT_CHANGE_SUCESS';
|
||||||
$h = G::encrypt($_POST['host'] . $sh . $_POST['user'] . $sh . $_POST['password'] . $sh . (1), $sh);
|
|
||||||
$insertStatements = "define ( 'HASH_INSTALLATION','{$h}' ); \ndefine ( 'SYSTEM_HASH', '{$sh}' ); \n";
|
|
||||||
$lines = [];
|
|
||||||
$content = '';
|
|
||||||
$filename = PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php';
|
|
||||||
$lines = file($filename);
|
|
||||||
|
|
||||||
$count = 1;
|
|
||||||
foreach ($lines as $line_num => $line) {
|
|
||||||
$pos = strpos($line, "define");
|
|
||||||
if ($pos !== false && $count < 3) {
|
|
||||||
$content = $content . $line;
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$content = "<?php \n" . $content . "\n" . $insertStatements . "\n";
|
$message = G::loadTranslation($id);
|
||||||
if (file_put_contents($filename, $content) != false) {
|
|
||||||
echo G::loadTranslation('ID_MESSAGE_ROOT_CHANGE_SUCESS');
|
|
||||||
} else {
|
|
||||||
echo G::loadTranslation('ID_MESSAGE_ROOT_CHANGE_FAILURE');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
echo $msgErr;
|
|
||||||
}
|
}
|
||||||
|
echo $message;
|
||||||
break;
|
break;
|
||||||
case 'captcha':
|
case 'captcha':
|
||||||
require_once PATH_TRUNK . 'vendor/dapphp/securimage/securimage.php';
|
require_once PATH_TRUNK . 'vendor/dapphp/securimage/securimage.php';
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Rebuilding the cases list cache and changing the MySQL credentials
|
||||||
|
*
|
||||||
|
* @see processWorkspace()
|
||||||
|
*
|
||||||
|
* @link https://wiki.processmaker.com/3.2/Clearing_the_Case_List_Cache
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ProcessMaker\Core\Installer;
|
||||||
|
|
||||||
global $RBAC;
|
global $RBAC;
|
||||||
$RBAC->requirePermissions('PM_SETUP');
|
$RBAC->requirePermissions('PM_SETUP');
|
||||||
// header('Pragma: no-cache');
|
// Define the content of the case list cache builder
|
||||||
// header('Cache-Control: no-store, no-cache, must-revalidate');
|
$headPublisher = headPublisher::getSingleton();
|
||||||
|
$headPublisher->addExtJsScript('setup/appCacheViewConf', false); //adding a javascript file .js
|
||||||
|
$headPublisher->addContent('setup/appCacheViewConf'); //adding a html file .html.
|
||||||
|
|
||||||
|
// Get some configurations
|
||||||
|
$conf = new Configurations();
|
||||||
|
$conf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
|
||||||
|
$lang = isset($conf->aConfig['LANG']) ? $conf->aConfig['LANG'] : 'en';
|
||||||
|
|
||||||
$oHeadPublisher = headPublisher::getSingleton();
|
// Assign the language configured
|
||||||
//$oHeadPublisher->setExtSkin( 'xtheme-blue');
|
$headPublisher->assign('currentLang', $lang);
|
||||||
|
|
||||||
|
// Get the mysql version
|
||||||
$oHeadPublisher->addExtJsScript('setup/appCacheViewConf', false); //adding a javascript file .js
|
$mysqlVersion = getMysqlVersion();
|
||||||
$oHeadPublisher->addContent('setup/appCacheViewConf'); //adding a html file .html.
|
$maxMysqlVersion = InstallerModule::MYSQL_VERSION_MAXIMUM_SUPPORTED;
|
||||||
|
if (version_compare($mysqlVersion, $maxMysqlVersion, '<')) {
|
||||||
$oConf = new Configurations();
|
$userNameMaxLength = 16;
|
||||||
$oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
|
|
||||||
|
|
||||||
//first check about APP_CACHE_VIEW is enabled or not,
|
|
||||||
if (isset($oConf->aConfig['LANG']) && isset($oConf->aConfig['STATUS']) && $oConf->aConfig['STATUS'] == 'active') {
|
|
||||||
$appCacheViewEnabled = true;
|
|
||||||
} else {
|
} else {
|
||||||
$appCacheViewEnabled = false;
|
$userNameMaxLength = 32;
|
||||||
}
|
}
|
||||||
$lang = isset($oConf->aConfig['LANG']) ? $oConf->aConfig['LANG'] : 'en';
|
$headPublisher->assign('userNameMaxLength', $userNameMaxLength);
|
||||||
|
|
||||||
//$oHeadPublisher->assign('appCacheViewEnabled', $appCacheViewEnabled);
|
G::RenderPage('publish', 'extJs');
|
||||||
|
|
||||||
|
|
||||||
$labels = G::getTranslations(array('ID_PROCESSING','ID_CACHE_LANGUAGE','ID_CACHE_HOST','ID_CACHE_USER','ID_CACHE_PASSWORD','ID_CACHE_TITLE_INFO','ID_CACHE_SUBTITLE_REBUILD','ID_CACHE_BTN_BUILD','ID_CACHE_BUILDING','ID_CACHE_SUBTITLE_SETUP_DB','ID_CACHE_BTN_SETUP_PASSWRD','ID_CACHE_SUBTITLE_SETUP_SESSION','ID_CACHE_BTN_SETUP_SESSION'
|
|
||||||
));
|
|
||||||
// $oHeadPublisher->assign('TRANSLATIONS', $labels);
|
|
||||||
// $TRANSLATIONS->ID_PROCESSING = G::LoadTranslation('ID_PROCESSING');
|
|
||||||
// $oHeadPublisher->assign( 'TRANSLATIONS', $TRANSLATIONS); //translations
|
|
||||||
$oHeadPublisher->assign('currentLang', $lang); //current language
|
|
||||||
|
|
||||||
|
|
||||||
G::RenderPage('publish', 'extJs');
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Session\TokenMismatchException;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use ProcessMaker\Model\User;
|
use ProcessMaker\Model\User;
|
||||||
|
|
||||||
@@ -586,3 +588,16 @@ function toSqlWithBindings(Illuminate\Database\Eloquent\Builder $queryObject) {
|
|||||||
// Return query
|
// Return query
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the mysql
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getMysqlVersion()
|
||||||
|
{
|
||||||
|
$results = DB::select(DB::raw("select version()"));
|
||||||
|
$mysqlVersion = $results[0]->{'version()'};
|
||||||
|
|
||||||
|
return $mysqlVersion;
|
||||||
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ Ext.onReady(function() {
|
|||||||
fieldLabel: _('ID_CACHE_USER'), // 'User',
|
fieldLabel: _('ID_CACHE_USER'), // 'User',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
name: 'user',
|
name: 'user',
|
||||||
|
autoCreate: {tag: 'input', type: 'text', size: userNameMaxLength, autocomplete: 'off', maxlength: userNameMaxLength},
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user