updated activation form

This commit is contained in:
davidegiarolo 2021-05-11 17:59:23 +02:00
parent 88977a0ec7
commit a6968cb29e
5 changed files with 499 additions and 703 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,216 +1,57 @@
<?php
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
// crmv@171581
if (!isset($root_directory)) {
require_once('../../config.inc.php');
chdir($root_directory);
}
require_once('include/utils/utils.php');
// crmv@171581e
//crmv@35153
$installation_mode = false;
if (empty($_SESSION)) {
VteSession::start();
}
if (VteSession::get('morph_mode') == 'installation') {
$installation_mode = true;
}
//crmv@35153e
// first activation
$first_activation = false;
$saved_morphsuit = getSavedMorphsuit();
if (empty($saved_morphsuit)) {
$first_activation = true;
}
global $adb, $table_prefix, $application_unique_key, $default_language;
$chiave = $_REQUEST['valida_chiave'];
if (isMorphsuitActive($chiave)) {
$adb->query('delete from tbl_s_morphsuit');
$adb->pquery('insert into tbl_s_morphsuit (morphsuit) values (?)',array($chiave));
//crmv@35153
if (isFreeVersion() && file_exists('modules/Update/free_changes')) {
$limits = array(
'numero_utenti'=>0,
'roles'=>3, //Organisation + 2
'profiles'=>2,
'pdf'=>1,
'adv_sharing_rules'=>1,
'sharing_rules_user'=>1,
);
$result = $adb->query("select * from {$table_prefix}_role");
if ($result && $adb->num_rows($result) > 0) {
if ($adb->num_rows($result) > $limits['roles']) {
$limits['roles'] = $adb->num_rows($result);
}
}
$result = $adb->query("select * from {$table_prefix}_profile");
if ($result && $adb->num_rows($result) > 0) {
if ($adb->num_rows($result) > $limits['profiles']) {
$limits['profiles'] = $adb->num_rows($result);
}
}
$result = $adb->query("SELECT COUNT(*) as count FROM {$table_prefix}_pdfmaker GROUP BY module");
if ($result && $adb->num_rows($result) > 0) {
$count = array();
while($row=$adb->fetchByAssoc($result)) {
$count[] = $row['count'];
}
if (!empty($count) && max($count) > $limits['pdf']) {
$limits['pdf'] = max($count);
}
}
$othermodules = getSharingModuleList();
if(!empty($othermodules)) {
$count = array();
foreach($othermodules as $moduleresname) {
$tmp = getAdvSharingRuleList($moduleresname);
$count[] = count($tmp);
}
if (!empty($count) && max($count) > $limits['adv_sharing_rules']) {
$limits['adv_sharing_rules'] = max($count);
}
}
$othermodules = getSharingModuleList(Array('Contacts'));
if(!empty($othermodules)) {
$result = $adb->query("SELECT id FROM {$table_prefix}_users WHERE status = 'Active' AND user_name <> 'admin'");
if ($result) {
$count = array();
while($row=$adb->fetchByAssoc($result)) {
foreach($othermodules as $moduleresname) {
$tmp = getSharingRuleListUser($moduleresname,$row['id']);
$count[] = count($tmp);
}
}
if (!empty($count) && max($count) > $limits['sharing_rules_user']) {
$limits['sharing_rules_user'] = max($count);
}
}
}
$saved_morphsuit = $chiave;
$saved_morphsuit = urldecode(trim($saved_morphsuit));
$private_key = substr($saved_morphsuit,0,strpos($saved_morphsuit,'-----'));
$enc_text = substr($saved_morphsuit,strpos($saved_morphsuit,'-----')+5);
$saved_morphsuit = @decrypt_morphsuit($private_key,$enc_text);
$saved_morphsuit = Zend_Json::decode($saved_morphsuit);
foreach($limits as $key => $limit) {
$saved_morphsuit[$key] = $limit;
}
$new_key = generate_key_pair_morphsuit();
$new_enc_text = encrypt_morphsuit($new_key['public_key'],Zend_Json::encode($saved_morphsuit));
$chiave = urlencode($new_key['private_key']."-----$new_enc_text");
$adb->query('delete from tbl_s_morphsuit');
$adb->pquery('insert into tbl_s_morphsuit (morphsuit) values (?)',array($chiave));
}
//crmv@35153e
itIsTimeToCheck('clear');
if (checkUsersMorphsuit()) {
//reset expiration date and zombie mode
VteSession::remove("checkDataMorphsuit");
VteSession::remove('alertDataMorphsuit');
VteSession::remove('MorphsuitZombie');
//crmv@35153
if (isFreeVersion() && !empty($_REQUEST['user_info'])) {
$user_info = Zend_Json::decode($_REQUEST['user_info']);
$new_password = $user_info['password'];
$user = CRMEntity::getInstance('Users');
$user->retrieve_entity_info(1,'Users');
$user->column_fields["user_name"] = $_REQUEST['user_name']; //crmv@61502
$user_hash = strtolower(md5($new_password));
$crypt_type = $user->DEFAULT_PASSWORD_CRYPT_TYPE;
$encrypted_new_password = $user->encrypt_password($new_password, $crypt_type);
// modifiche utente
$query = "update {$table_prefix}_users set user_name = ?, last_name = ?, email1 = ?, user_password = ?, confirm_password = ?, user_hash=?, crypt_type=?";
$params = array($user_info['username'], $user_info['name'], $user_info['email'], $encrypted_new_password, $encrypted_new_password, $user_hash, $crypt_type);
$query .= " where id = 1";
$res = $adb->pquery($query,$params);
//if ($adb->getAffectedRowCount($res) <= 0) die('Error updating admin user');
if ($adb->isOracle()) {
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = NULL, last_change_pwd = ? WHERE userid = ?", array(date('Y-m-d H:i:s'),1));
} else {
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = ?, last_change_pwd = ? WHERE userid = ?", array('0000-00-00 00:00:00',date('Y-m-d H:i:s'),1));
}
// file dei privilegi
$priv_file = $root_directory.'user_privileges/user_privileges_1.php';
$userfile = file_get_contents($priv_file);
$userfile = preg_replace("/'user_name'\s*=>\s*[^,]+,/", "'user_name'=>'{$user_info['username']}',", $userfile);
$userfile = preg_replace("/'user_password'\s*=>\s*[^,]+,/", "'user_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'confirm_password'\s*=>\s*[^,]+,/", "'confirm_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'user_hash'\s*=>\s*[^,]+,/", "'user_hash'=>'{$user_hash}',", $userfile);
$userfile = preg_replace("/'last_name'\s*=>\s*[^,]+,/", "'last_name'=>'{$user_info['name']}',", $userfile);
$userfile = preg_replace("/'email1'\s*=>\s*[^,]+,/", "'email1'=>'{$user_info['email']}',", $userfile);
if (!file_put_contents($priv_file, $userfile)) die('Error updating user_privileges file');
} elseif ($installation_mode && isset($_REQUEST['user_name'])) {
$new_password = $_REQUEST['user_password'];
$user = CRMEntity::getInstance('Users');
$user->retrieve_entity_info(1,'Users');
$user->column_fields["user_name"] = $_REQUEST['user_name']; //crmv@61502
$user_hash = strtolower(md5($new_password));
$crypt_type = $user->DEFAULT_PASSWORD_CRYPT_TYPE;
$encrypted_new_password = $user->encrypt_password($new_password, $crypt_type);
// modifiche utente
$query = "update {$table_prefix}_users set user_name = ?, first_name = ?, last_name = ?, email1 = ?, user_password = ?, confirm_password = ?, user_hash=?, crypt_type=?";
$params = array($_REQUEST['user_name'], $_REQUEST['first_name'], $_REQUEST['last_name'], $_REQUEST['email1'], $encrypted_new_password, $encrypted_new_password, $user_hash, $crypt_type);
$query .= " where id = 1";
$res = $adb->pquery($query,$params);
//if ($adb->getAffectedRowCount($res) <= 0) die('Error updating admin user');
if ($adb->isOracle() || $adb->isMssql()) { // crmv@155585
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = NULL, last_change_pwd = ? WHERE userid = ?", array(date('Y-m-d H:i:s'),1));
} else {
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = ?, last_change_pwd = ? WHERE userid = ?", array('0000-00-00 00:00:00',date('Y-m-d H:i:s'),1));
}
// file dei privilegi
$priv_file = $root_directory.'user_privileges/user_privileges_1.php';
$userfile = file_get_contents($priv_file);
$userfile = preg_replace("/'user_name'\s*=>\s*[^,]+,/", "'user_name'=>'{$_REQUEST['user_name']}',", $userfile);
$userfile = preg_replace("/'user_password'\s*=>\s*[^,]+,/", "'user_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'confirm_password'\s*=>\s*[^,]+,/", "'confirm_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'user_hash'\s*=>\s*[^,]+,/", "'user_hash'=>'{$user_hash}',", $userfile);
$userfile = preg_replace("/'first_name'\s*=>\s*[^,]+,/", "'first_name'=>'{$_REQUEST['first_name']}',", $userfile);
$userfile = preg_replace("/'last_name'\s*=>\s*[^,]+,/", "'last_name'=>'{$_REQUEST['last_name']}',", $userfile);
$userfile = preg_replace("/'email1'\s*=>\s*[^,]+,/", "'email1'=>'{$_REQUEST['email']}',", $userfile);
if (!file_put_contents($priv_file, $userfile)) die('Error updating user_privileges file');
}
if ($installation_mode) {
//autologin
VteSession::set("authenticated_user_id", 1);
VteSession::set("app_unique_key", $application_unique_key);
VteSession::set('authenticated_user_language', $default_language);
}
//crmv@35153e
CRMVUtils::writeCFPrefix(); // crmv@195213
die('yes');
}
}
die('no');
?>
<?php
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
// crmv@171581
if (!isset($root_directory)) {
require_once('../../config.inc.php');
chdir($root_directory);
}
require_once('include/utils/utils.php');
// crmv@171581e
//crmv@35153
$installation_mode = false;
if (empty($_SESSION)) {
VteSession::start();
}
if (VteSession::get('morph_mode') == 'installation') {
$installation_mode = true;
}
//crmv@35153e
/* crmv@130421 */
vtlib_toggleModuleAccess('Morphsuit',false);
$user_info = Zend_Json::decode($_REQUEST['user_info']);
$new_password = $user_info['password'];
$user = CRMEntity::getInstance('Users');
$user->retrieve_entity_info(1,'Users');
$user_hash = strtolower(md5($new_password));
$crypt_type = $user->DEFAULT_PASSWORD_CRYPT_TYPE;
$encrypted_new_password = $user->encrypt_password($new_password, $crypt_type);
// modifiche utente
$res = $adb->pquery("update {$table_prefix}_users set user_name = ?, last_name = ?, first_name = ?, email1 = ?, user_password = ?, confirm_password = ?, user_hash=?, crypt_type=? where id = 1", array($user_info['username'], $user_info['last_name'], $user_info['first_name'], $user_info['email'], $encrypted_new_password, $encrypted_new_password, $user_hash, $crypt_type));
if ($adb->getAffectedRowCount($res) <= 0) die('Error updating admin user');
if ($adb->isOracle()) {
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = NULL, last_change_pwd = ? WHERE userid = ?", array(date('Y-m-d H:i:s'),1));
} else {
$adb->pquery("UPDATE {$table_prefix}_check_pwd SET last_login = ?, last_change_pwd = ? WHERE userid = ?", array('0000-00-00 00:00:00',date('Y-m-d H:i:s'),1));
}
// file dei privilegi
$priv_file = $root_directory.'user_privileges/user_privileges_1.php';
$userfile = file_get_contents($priv_file);
$userfile = preg_replace("/'user_password'\s*=>\s*[^,]+,/", "'user_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'confirm_password'\s*=>\s*[^,]+,/", "'confirm_password'=>'{$encrypted_new_password}',", $userfile);
$userfile = preg_replace("/'user_hash'\s*=>\s*[^,]+,/", "'user_hash'=>'{$user_hash}',", $userfile);
$userfile = preg_replace("/'last_name'\s*=>\s*[^,]+,/", "'last_name'=>'{$user_info['last_name']}',", $userfile);
$userfile = preg_replace("/'first_name'\s*=>\s*[^,]+,/", "'first_name'=>'{$user_info['first_name']}',", $userfile);
$userfile = preg_replace("/'email1'\s*=>\s*[^,]+,/", "'email1'=>'{$user_info['email']}',", $userfile);
if (!file_put_contents($priv_file, $userfile)) die('Error updating user_privileges file');
die('yes');

View File

@ -1,5 +1,5 @@
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/

View File

@ -1,79 +1,79 @@
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
function alertDataMorphsuit() {
jQuery.ajax({
url: 'index.php',
method: 'POST',
data: 'module=Morphsuit&action=MorphsuitAjax&file=RequestMorphsuit&type=time_expired',
success: function(result) {
jQuery('#checkDataMorphsuit').html(result);
if (getObj('freezeMorphsuit') == null) {
var oFreezeLayerMorphsuit = document.createElement("DIV");
oFreezeLayerMorphsuit.id = "freezeMorphsuit";
oFreezeLayerMorphsuit.className = "small veil_new";
if (browser_ie) oFreezeLayerMorphsuit.style.height = (document.body.offsetHeight + (document.body.scrollHeight - document.body.offsetHeight)) + "px";
else if (browser_nn4 || browser_nn6) oFreezeLayerMorphsuit.style.height = document.body.offsetHeight + "px";
oFreezeLayerMorphsuit.style.width = "100%";
document.body.appendChild(oFreezeLayerMorphsuit);
jQuery('#freezeMorphsuit').css('z-index','10000002');
}
jQuery('#checkDataMorphsuit').show();
placeAtCenter(getObj('checkDataMorphsuit'));
getObj('checkDataMorphsuit').style.top = '0px';
}
});
}
function checkUsersMorphsuit(userid,mode,user_status) {
res = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckUsersMorphsuit&userid='+userid+'&mode='+mode+'&user_status='+user_status);
var result = false;
if (res == 'yes' || res.indexOf("images/denied.gif")>-1) { //se il modulo è disattivato permetto
result = true;
}
return result;
}
function isFreeVersion() {
res = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=IsFreeVersion');
var result = false;
if (res == 'yes') {
result = true;
}
return result;
}
function CheckAvailableVersion(vteUpdateServer,actual_version,day) {
var params = {
'check_version' : 'yes',
'actual_version' : actual_version
}
jQuery.ajax({
url : vteUpdateServer,
type: 'POST',
data: params,
//async: false,
complete : function(res, status) {
if (res.responseText == 'yes'){
CheckAvailableVersionProcess(day);
} else {
var url = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=SetCheckAvailableVersion';
if (day != undefined) {
url += '&day='+day;
}
getFile(url);
}
}
});
}
function CheckAvailableVersionProcess(day) {
CheckAvailableVersion_callback = document.getElementById("CheckAvailableVersionDiv");
if(CheckAvailableVersion_callback == null) return;
CheckAvailableVersion_callback.style.display = 'block';
var url = '';
if (day != undefined) {
url += '&day='+day;
}
CheckAvailableVersion_callback.innerHTML = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckAvailableVersionDiv'+url);
}
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
function alertDataMorphsuit() {
jQuery.ajax({
url: 'index.php',
method: 'POST',
data: 'module=Morphsuit&action=MorphsuitAjax&file=RequestMorphsuit&type=time_expired',
success: function(result) {
jQuery('#checkDataMorphsuit').html(result);
if (getObj('freezeMorphsuit') == null) {
var oFreezeLayerMorphsuit = document.createElement("DIV");
oFreezeLayerMorphsuit.id = "freezeMorphsuit";
oFreezeLayerMorphsuit.className = "small veil_new";
if (browser_ie) oFreezeLayerMorphsuit.style.height = (document.body.offsetHeight + (document.body.scrollHeight - document.body.offsetHeight)) + "px";
else if (browser_nn4 || browser_nn6) oFreezeLayerMorphsuit.style.height = document.body.offsetHeight + "px";
oFreezeLayerMorphsuit.style.width = "100%";
document.body.appendChild(oFreezeLayerMorphsuit);
jQuery('#freezeMorphsuit').css('z-index','10000002');
}
jQuery('#checkDataMorphsuit').show();
placeAtCenter(getObj('checkDataMorphsuit'));
getObj('checkDataMorphsuit').style.top = '0px';
}
});
}
function checkUsersMorphsuit(userid,mode,user_status) {
res = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckUsersMorphsuit&userid='+userid+'&mode='+mode+'&user_status='+user_status);
var result = false;
if (res == 'yes' || res.indexOf("images/denied.gif")>-1) { //se il modulo è disattivato permetto
result = true;
}
return result;
}
function isFreeVersion() {
res = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=IsFreeVersion');
var result = false;
if (res == 'yes') {
result = true;
}
return result;
}
function CheckAvailableVersion(vteUpdateServer,actual_version,day) {
var params = {
'check_version' : 'yes',
'actual_version' : actual_version
}
jQuery.ajax({
url : vteUpdateServer,
type: 'POST',
data: params,
//async: false,
complete : function(res, status) {
if (res.responseText == 'yes'){
CheckAvailableVersionProcess(day);
} else {
var url = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=SetCheckAvailableVersion';
if (day != undefined) {
url += '&day='+day;
}
getFile(url);
}
}
});
}
function CheckAvailableVersionProcess(day) {
CheckAvailableVersion_callback = document.getElementById("CheckAvailableVersionDiv");
if(CheckAvailableVersion_callback == null) return;
CheckAvailableVersion_callback.style.display = 'block';
var url = '';
if (day != undefined) {
url += '&day='+day;
}
CheckAvailableVersion_callback.innerHTML = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckAvailableVersionDiv'+url);
}

View File

@ -1,402 +1,357 @@
<?php
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
/* crmv@35153 crmv@54179 crmv@103922 */
// crmv@198545
if (!isset($root_directory)) {
require_once('../../config.inc.php');
chdir($root_directory);
}
require_once('include/utils/utils.php');
// crmv@198545e
$installation_mode = false;
if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') == 'installation') {
$installation_mode = true;
// crmv@198545 - removed code
if (isMorphsuitActive()) {
exit;
}
global $enterprise_mode; // crmv@192073
include('vteversion.php'); // crmv@181168
VteSession::start();
VteSession::set('morph_mode', 'installation');
if ($enterprise_mode == 'VTENEXTCE') { // crmv@192073
// recalc application_unique_key
$application_unique_key = md5(time() . rand(1,9999999) . md5($root_directory));
$configInc = file_get_contents('config.inc.php');
$configInc = preg_replace('/^\$application_unique_key.*$/m', "\$application_unique_key = '{$application_unique_key}';", $configInc);
if (is_writable('config.inc.php')) file_put_contents('config.inc.php', $configInc);
// recalc admin accesskey
require_once 'include/Webservices/Utils.php';
$accesskey = vtws_generateRandomAccessKey(16);
$adb->pquery("update {$table_prefix}_users set accesskey=? where id=?",array($accesskey,1));
$priv_file = $root_directory.'user_privileges/user_privileges_1.php';
$userfile = file_get_contents($priv_file);
$userfile = preg_replace("/'accesskey'\s*=>\s*[^,]+,/", "'accesskey'=>'{$accesskey}',", $userfile);
if (is_writable($priv_file)) file_put_contents($priv_file, $userfile);
} // crmv@192073
}
$update_mode = false;
if (file_exists('modules/Update/free_changes') && getUserName(1) == 'admin') {
$update_mode = true;
} elseif (getUserName(1) != 'admin') {
$username_free = getUserName(1);
}
if (isFreeVersion()) {
$morph_activation_message = '<b>'.$mod_strings['LBL_MORPHSUIT_BUSINESS_ACTIVATION'].'</b>';
} else {
$morph_activation_message = $mod_strings['LBL_MORPHSUIT_TIME_EXPIRED'];
}
include('modules/Morphsuit/HeaderMorphsuit.php');
$focus = CRMEntity::getInstance('Morphsuit');
($installation_mode) ? $path = '../../' : $path = '';
$sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $enterprise_current_version";
?>
<body>
<div id="main-container" class="container">
<div class="row">
<div class="col-xs-offset-1 col-xs-10">
<div id="content" class="col-xs-12">
<div id="content-cont" class="col-xs-12">
<div id="content-inner-cont" class="col-xs-12">
<div class="col-xs-12 content-padding">
<div class="col-xs-8 vcenter text-left">
<h2><?php echo $sectionTitle; ?></h2>
</div><!--
--><div class="col-xs-4 nopadding vcenter text-right">
<a href="<?php echo $enterprise_website[0]; ?>" target="_blank">
<img src="<?php echo $path; ?>themes/logos/vtenext.png" />
</a>
</div>
<div class="col-xs-12 text-center content-padding">
<h4><?php echo $morph_activation_message.'<br />'.$mod_strings['LBL_MORPHSUIT_SITE_LOGIN']; ?>&nbsp;your VTECRM LTD Partner Account.</h4>
</div>
</div>
<div id="config" class="col-xs-12">
<div class="col-xs-12">
<div class="col-xs-8 col-xs-offset-2">
<?php if ($installation_mode) { ?>
<form action="SendMorphsuit.php" method="post" id="MorphsuitForm">
<?php } else { ?>
<form action="index.php" method="post" id="MorphsuitForm">
<?php } ?>
<input type="hidden" name="module" value="Morphsuit">
<input type="hidden" name="action" value="MorphsuitAjax">
<input type="hidden" name="file" value="SendMorphsuit">
<input type="hidden" name="type" value="<?php echo $_REQUEST['type']; ?>">
<input type="hidden" name="vte_user_info" value="">
<table class="table borderless" id="Standard">
<tr>
<td align="left">
<label for="username_std">Username:</label>
<div class="dvtCellInfo">
<input id="username_std" name="username_std" class="small detailedViewTextBox" value="" type="text" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std">Password:</label>
<div class="dvtCellInfo">
<input id="password_std" name="password_std" class="small detailedViewTextBox" value="" type="password" />
</div>
</td>
</tr>
<tr height="20px"><td align="center" colspan="2"></td></tr>
<tr>
<td align="left">
<label for="tipo_installazione"><?php echo $mod_strings['LBL_MORPHSUIT_INSTALLATION_TYPE']; ?>:</label>
<div class="dvtCellInfo">
<select id="tipo_installazione" name="tipo_installazione" class="small detailedViewTextBox">
<option value="produzione"><?php echo $mod_strings['LBL_MORPHSUIT_PROD']; ?></option>
<option value="test"><?php echo $mod_strings['LBL_MORPHSUIT_TEST']; ?></option>
<option value="demo"><?php echo $mod_strings['LBL_MORPHSUIT_DEMO']; ?></option>
</select>
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="durata_installazione"><?php echo $mod_strings['LBL_MORPHSUIT_INSTALLATION_LENGTH']; ?>:</label>
<div class="dvtCellInfo">
<select id="durata_installazione" name="durata_installazione" class="small detailedViewTextBox">
<option value="1 year"><?php echo $mod_strings['LBL_MORPHSUIT_1Y']; ?></option>
<option value="6 months"><?php echo $mod_strings['LBL_MORPHSUIT_6M']; ?></option>
<option value="30 days"><?php echo $mod_strings['LBL_MORPHSUIT_30D']; ?></option>
<option value="15 days"><?php echo $mod_strings['LBL_MORPHSUIT_15D']; ?></option>
<option value="1 day"><?php echo $mod_strings['LBL_MORPHSUIT_1D']; ?></option>
</select>
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="numero_utenti"><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER']; ?>:</label>
<div class="dvtCellInfo">
<select id="numero_utenti" name="numero_utenti" class="small detailedViewTextBox">
<option value="9"><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER_10']; ?></option>
<option value="19"><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER_20']; ?></option>
<option value="49"><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER_50']; ?></option>
<option value="99"><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER_100']; ?></option>
<option value=""><?php echo $mod_strings['LBL_MORPHSUIT_USER_NUMBER_UNLIMITED']; ?></option>
</select>
</div>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td colspan="2" align="center">
<div class="dvtCellInfo">
<textarea class="small detailedViewTextBox" style="resize:vertical" readonly><?php echo getTranslatedString('LBL_PRIVACY_DESC','Settings'); ?></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<div class="checkbox">
<label for="privacy_flag_std"><input type="checkbox" id="privacy_flag_std" name="privacy_flag_std" />&nbsp;&nbsp;<b><?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?></b></label>
</div>
</td>
</tr>
</table>
</form>
</div>
</div>
<div id="nav-bar" class="col-xs-12 nopadding">
<div id="nav-bar-inner" class="col-xs-12 text-right">
<?php if ($_REQUEST['type'] == 'time_expired') { ?>
<button type="button" onClick="zombieMorph();" class="crmbutton small delete"><?php echo getTranslatedString('LBL_ZOMBIE_MODE','Morphsuit'); ?></button>
<?php } ?>
<button type="button" onClick="if (validate()) submitStd();" class="crmbutton small edit btn-arrow-right"><?php echo $mod_strings['LBL_MORPHSUIT_NEXT']; ?></button>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer" class="col-xs-12 content-padding">
<div id="footer-inner" class="col-xs-12 content-padding text-center">
<div class="spacer-50"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var currentTab;
currentTab = 'Standard';
function validate() {
if (currentTab == 'Free') {
if (!emptyCheck('username_free','Username',getObj('username_free').type))
return false;
if (!emptyCheck('password_free','Password',getObj('password_free').type))
return false;
if (!emptyCheck('privacy_flag_free','<?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?> ',getObj('privacy_flag_free').type))
return false;
return true;
} else {
if (!emptyCheck('username_std','Username',getObj('username_std').type))
return false;
if (!emptyCheck('password_std','Password',getObj('password_std').type))
return false;
if (!emptyCheck('privacy_flag_std','<?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?> ',getObj('privacy_flag_std').type))
return false;
//login
pleaseWait('enable');
var url = '<?php echo $focus->vteFreeServer; ?>';
var params = {
'method' : 'checkUserCredentials'
};
jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('username_std').value},async:false,
complete : function(res, status) { params['username'] = res.responseText; }
});
jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('password_std').value},async:false,
complete : function(res, status) { params['password'] = res.responseText; }
});
var result = '';
jQuery.ajax({
url : url,
type: 'POST',
data: params,
complete : function(res, status) {
if (status != 'success') {
alert('Connection with VTECRM Network failed ('+status+')');
pleaseWait('disable');
return false;
} else {
result = res.responseText;
if (result == false) {
alert('Login failed');
pleaseWait('disable');
return false;
} else {
getObj('vte_user_info').value = result;
document.forms['MorphsuitForm'].submit();
}
}
}
});
}
}
function submitStd() {
document.forms['MorphsuitForm'].submit();
}
function success(response) {
jQuery('#checkDataMorphsuit').html(response);
placeAtCenter(getObj('checkDataMorphsuit'));
getObj('checkDataMorphsuit').style.top = '0px';
}
function zombieMorph() {
window.location.href = "index.php?module=Morphsuit&action=MorphsuitAjax&file=Zombie";
}
function submitFree() {
pleaseWait('enable');
<?php if ($installation_mode) { ?>
var key = getFile('<?php echo $path; ?>modules/Morphsuit/SendMorphsuit.php?tipo_installazione=Free');
<?php } else { ?>
var key = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=SendMorphsuit&tipo_installazione=Free');
<?php } ?>
var url = '<?php echo $focus->vteFreeServer; ?>';
var params = {
'method' : 'generateMorphsuit',
'revision' : '<?php echo $enterprise_current_build; ?>',
'subversion' : '<?php echo $enterprise_subversion; ?>',
<?php
$saved_morphsuit = getSavedMorphsuit();
if (!empty($saved_morphsuit)) {
$saved_morphsuit = urldecode(trim($saved_morphsuit));
$private_key = substr($saved_morphsuit,0,strpos($saved_morphsuit,'-----'));
$enc_text = substr($saved_morphsuit,strpos($saved_morphsuit,'-----')+5);
$saved_morphsuit = @decrypt_morphsuit($private_key,$enc_text);
$saved_morphsuit = Zend_Json::decode($saved_morphsuit);
$saved_morphsuit_id = $saved_morphsuit['id'];
echo "'id' : '{$saved_morphsuit_id}',";
}
?>
'key' : key
};
jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('username_free').value},async:false,
complete : function(res, status) { params['username'] = res.responseText; }
});
jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('password_free').value},async:false,
complete : function(res, status) { params['password'] = res.responseText; }
});
var result = '';
jQuery.ajax({
url : url,
type: 'POST',
data: params,
complete : function(res, status) {
if (status != 'success') {
alert('Connection with VTECRM Network failed ('+status+')');
pleaseWait('disable');
} else {
result = res.responseText;
if (result == 'LOGIN_FAILED') {
alert('Login failed (err 1)');
pleaseWait('disable');
} else if (result == 'USER_NOT_IMPORTED') {
alert('Login failed (err 2)');
pleaseWait('disable');
} else if (result == 'VERSION_NOT_ACTIVABLE') {
alert('<?php echo addslashes($mod_strings['LBL_ERROR_VTE_FREE_NOT_ACTIVABLE']); ?>');
pleaseWait('disable');
} else if (result.indexOf('ERROR: The requested URL could not be retrieved')>-1) {
alert('Connection with VTECRM Network failed (err 3)');
pleaseWait('disable');
} else if (result == '') {
alert('VTECRM Network service fails to create your license (err 4)');
pleaseWait('disable');
} else {
result = eval('('+result+')');
var new_key = result['new_key'];
var user_info = {
'username' : getObj('username_free').value,
'password' : getObj('password_free').value,
'email' : result['email'],
'name' : result['name']
};
<?php if ($installation_mode) { ?>
var url1 = '<?php echo $path; ?>modules/Morphsuit/CheckMorphsuit.php';
<?php } else { ?>
var url1 = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckMorphsuit';
<?php } ?>
var params1 = {
'valida_chiave' : new_key,
'user_info' : JSON.stringify(user_info)
};
jQuery.ajax({
url : url1,
type: 'POST',
data: params1,
complete : function(res1, status1) {
var check = res1.responseText;
if (check != 'yes') {
alert('VTECRM Network service fails to create your license (err 5)');
} else if (check == 'yes') {
var res1 = getFile('<?php echo $path; ?>index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckSMTP');
if (res1 != 'ok') {
// crmv@99315
vteconfirm("<?php echo $mod_strings['LBL_ERROR_SMTP']; ?>", function(yes) {
if (yes) {
window.location.href = "<?php echo $path; ?>index.php?module=Settings&action=EmailConfig&parenttab=Settings";
} else {
window.location.href = "<?php echo $path; ?>index.php";
}
});
return;
// crmv@99315e
}
}
window.location.href = "<?php echo $path; ?>index.php";
}
});
}
}
}
});
}
function pleaseWait(status) {
if (status == 'enable') {
VteJS_DialogBox.progress();
} else {
VteJS_DialogBox.hideprogress();
}
}
</script>
</body>
</html>
<?php die; ?>
<?php
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
/* crmv@130421 */
// crmv@198545
if (!isset($root_directory)) {
require_once('../../config.inc.php');
chdir($root_directory);
}
require_once('include/utils/utils.php');
// crmv@198545e
//crmv@35153 crmv@69514 crmv@69892
$installation_mode = false;
if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') == 'installation') {
$installation_mode = true;
// crmv@198545 - removed code
if (isMorphsuitActive()) {
exit;
}
global $enterprise_mode; // crmv@192073
include('vteversion.php'); // crmv@181168
VteSession::start();
VteSession::set('morph_mode', 'installation');
if ($enterprise_mode == 'VTENEXTCE') { // crmv@192073
// recalc application_unique_key
$application_unique_key = md5(time() + rand(1,9999999) + md5($root_directory));
$configInc = file_get_contents('config.inc.php');
$configInc = preg_replace('/^\$application_unique_key.*$/m', "\$application_unique_key = '{$application_unique_key}';", $configInc);
if (is_writable('config.inc.php')) file_put_contents('config.inc.php', $configInc);
// recalc admin accesskey
require_once 'include/Webservices/Utils.php';
$accesskey = vtws_generateRandomAccessKey(16);
$adb->pquery("update {$table_prefix}_users set accesskey=? where id=?",array($accesskey,1));
$priv_file = $root_directory.'user_privileges/user_privileges_1.php';
$userfile = file_get_contents($priv_file);
$userfile = preg_replace("/'accesskey'\s*=>\s*[^,]+,/", "'accesskey'=>'{$accesskey}',", $userfile);
if (is_writable($priv_file)) file_put_contents($priv_file, $userfile);
} // crmv@192073
}
$update_mode = false;
if (file_exists('modules/Update/free_changes') && getUserName(1) == 'admin') {
$update_mode = true;
} elseif (getUserName(1) != 'admin') {
$username_free = getUserName(1);
}
//crmv@35153e
($installation_mode) ? $path = '../../' : $path = '';
require_once('data/CRMEntity.php');
require_once('modules/Morphsuit/Morphsuit.php');
include('modules/Morphsuit/HeaderMorphsuit.php');
$focus = new Morphsuit();
$focusUsers = CRMEntity::getInstance('Users');
$lbl_not_safety_password = sprintf(getTranslatedString('LBL_NOT_SAFETY_PASSWORD','Users'),$focusUsers->password_length_min);
$sectionTitle = 'Administrator user activation';
?>
<body>
<div id="main-container" class="container">
<div class="row">
<div class="col-xs-offset-2 col-xs-8">
<div id="content" class="col-xs-12">
<div id="content-cont" class="col-xs-12">
<div id="content-inner-cont" class="col-xs-12">
<div class="col-xs-12 content-padding">
<div class="col-xs-8 vcenter text-left">
<h2><?php echo $sectionTitle; ?></h2>
</div><!--
--><div class="col-xs-4 nopadding vcenter text-right">
<a href="<?php echo $enterprise_website[0]; ?>" target="_blank">
<img src="<?php echo $path; ?>themes/logos/vtenext.png" />
</a>
</div>
</div>
<div id="config" class="col-xs-12">
<div class="col-xs-12">
<div class="col-xs-12">
<?php if ($installation_mode) { ?>
<form action="SendMorphsuit.php" method="post" id="MorphsuitForm">
<?php } else { ?>
<form action="index.php" method="post" id="MorphsuitForm">
<?php } ?>
<input type="hidden" name="module" value="Morphsuit">
<input type="hidden" name="action" value="MorphsuitAjax">
<input type="hidden" name="file" value="SendMorphsuit">
<input type="hidden" name="type" value="<?php echo $_REQUEST['type']; ?>">
<input type="hidden" name="vte_user_info" value="">
<table class="table borderless" id="Standard">
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('User Name','Users'); ?></label>
<div class="dvtCellInfo">
<input id="username_std" name="username_std" class="small detailedViewTextBox" value="admin" type="text" disabled="true" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('Email'); ?></label>
<div class="dvtCellInfoM">
<input id="email_std" name="email_std" class="small detailedViewTextBox" value="" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('First Name','Users'); ?></label>
<div class="dvtCellInfo">
<input id="first_name" name="first_name" class="small detailedViewTextBox" value="" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('Last Name','Users'); ?></label>
<div class="dvtCellInfo">
<input id="last_name" name="last_name" class="small detailedViewTextBox" value="" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('Company','Leads'); ?></label>
<div class="dvtCellInfo">
<input id="company" name="company" class="small detailedViewTextBox" value="" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('LBL_MORPH_NEWSLETTER_LANG','Morphsuit'); ?></label>
<div class="dvtCellInfo">
<select id="newsletter_lang" name="newsletter_lang" class="small detailedViewTextBox">
<option value="ENG" selected="">English</option>
<option value="ITA">Italian</option>
<option value="DEU">German</option>
<option value="DUT">Dutch</option>
</select>
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std">Password:</label>
<div class="dvtCellInfoM">
<input id="password_std" name="password_std" class="small detailedViewTextBox" value="" type="password" />
</div>
</td>
</tr>
<tr>
<td align="left">
<label for="username_std"><?php echo getTranslatedString('Confirm Password','Users'); ?></label>
<div class="dvtCellInfoM">
<input id="confirm_password_std" name="confirm_password_std" value="" type="password" class="detailedViewTextBox" />
</div>
</td>
</tr>
<tr height="20px"><td align="center" colspan="2"></td></tr>
<tr>
<td colspan="2" align="center">
<div class="dvtCellInfo">
<textarea class="small detailedViewTextBox" style="resize:vertical; height:90px" readonly><?php echo getTranslatedString('LBL_PRIVACY_DESC','Settings'); ?></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<div class="checkbox">
<label for="privacy_flag_std"><input type="checkbox" id="privacy_flag_std" name="privacy_flag_std" />&nbsp;&nbsp;<b><?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?></b></label>
</div>
</td>
</tr>
</table>
</form>
</div>
</div>
<div id="nav-bar" class="col-xs-12 nopadding">
<div id="nav-bar-inner" class="col-xs-12 text-right">
<?php if ($_REQUEST['type'] == 'time_expired') { ?>
<button type="button" onClick="zombieMorph();" class="crmbutton small delete"><?php echo getTranslatedString('LBL_ZOMBIE_MODE','Morphsuit'); ?></button>
<?php } ?>
<!--
<button type="button" onClick="if (validate()) submitStd();" class="crmbutton small edit btn-arrow-right"><?php echo $mod_strings['LBL_MORPHSUIT_NEXT']; ?></button>
-->
<input type="button" onClick="if (validateUser()) submitCreateUser();" class="crmbutton small save" value="<?php echo getTranslatedString('LBL_MORPHSUIT_REGISTER','Morphsuit'); ?>" />
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer" class="col-xs-12 content-padding">
<div id="footer-inner" class="col-xs-12 content-padding text-center">
<div class="spacer-50"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// crmv@69514
var createUser = true;
function validateUser() {
//if (!emptyCheck('last_name','Last Name',getObj('last_name').type)) return false;
if (!emptyCheck('email_std','Email',getObj('email_std').type)) return false;
if (!patternValidate('email_std','Email','email')) return false;
if (!emptyCheck('password_std','Password',getObj('password_std').type)) return false;
if (!emptyCheck('confirm_password_std','Password',getObj('confirm_password_std').type)) return false;
if (getObj('password_std').value != getObj('confirm_password_std').value) {
alert("<?php echo getTranslatedString('ERR_REENTER_PASSWORDS','Morphsuit'); ?>");
return false;
}
var checkPasswValues = {'user_name':'admin','first_name':getObj('first_name').value,'last_name':getObj('last_name').value};
<?php if ($installation_mode) { ?>
var res = getFile('<?php echo $path; ?>modules/Users/CheckPasswordCriteria.php?record=&password='+getObj('password_std').value+'&row='+encodeURIComponent(JSON.stringify(checkPasswValues)));
<?php } else { ?>
var res = getFile('index.php?module=Users&action=UsersAjax&file=CheckPasswordCriteria&record=&password='+getObj('password_std').value+'&row='+encodeURIComponent(JSON.stringify(checkPasswValues)));
<?php } ?>
if (res == "no") {
alert('<?php echo $lbl_not_safety_password; ?>');
return false;
}
if (!emptyCheck('privacy_flag_std','<?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?> ',getObj('privacy_flag_std').type)) return false;
return true;
}
function success(response) {
jQuery('#checkDataMorphsuit').html(response);
placeAtCenter(getObj('checkDataMorphsuit'));
getObj('checkDataMorphsuit').style.top = '0px';
}
function submitCreateUser() {
pleaseWait('enable');
var params = 'tipo_installazione=Free&email='+getObj('email_std').value;
<?php if ($installation_mode) { ?>
var key = getFile('<?php echo $path; ?>modules/Morphsuit/SendMorphsuit.php?'+params);
<?php } else { ?>
var key = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=SendMorphsuit&'+params);
<?php } ?>
var url = '<?php echo $focus->vteFreeServer; ?>';
var params = {
'method' : 'generateMorphsuitCommunityUser',
'revision' : '<?php echo $enterprise_current_build; ?>',
'subversion' : '<?php echo $enterprise_subversion; ?>',
<?php
$saved_morphsuit = getSavedMorphsuit();
if (!empty($saved_morphsuit)) {
$saved_morphsuit = urldecode(trim($saved_morphsuit));
$private_key = substr($saved_morphsuit,0,strpos($saved_morphsuit,'-----'));
$enc_text = substr($saved_morphsuit,strpos($saved_morphsuit,'-----')+5);
$saved_morphsuit = @decrypt_morphsuit($private_key,$enc_text);
$saved_morphsuit = Zend_Json::decode($saved_morphsuit);
$saved_morphsuit_id = $saved_morphsuit['id'];
echo "'id' : '{$saved_morphsuit_id}',";
}
?>
'first_name' : getObj('first_name').value,
'last_name' : getObj('last_name').value,
'company' : getObj('company').value,
'newsletter_lang' : jQuery('#newsletter_lang').val(),
'key' : key
};
jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('email_std').value},async:false,
complete : function(res, status) { params['email'] = res.responseText; }
});
var result = '';
jQuery.ajax({
url : url,
type: 'POST',
data: params,
complete : function(res, status) {
checkMorphsuit();
}
});
}
function checkMorphsuit(new_key, user_info) {
var user_info = {
'username' : getObj('username_std').value,
'password' : getObj('password_std').value,
'email' : getObj('email_std').value,
'last_name' : getObj('last_name').value,
'first_name' : getObj('first_name').value
};
<?php if ($installation_mode) { ?>
var url = '<?php echo $path; ?>modules/Morphsuit/CheckMorphsuit.php';
<?php } else { ?>
var url = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckMorphsuit';
<?php } ?>
var params = {
'user_info' : JSON.stringify(user_info)
};
jQuery.ajax({
url : url,
type: 'POST',
data: params,
complete : function(res1, status1) {
var check = res1.responseText;
if (check != 'yes') {
//alert('VTECRM Network service fails to create your license (err 5)');
pleaseWait('disable');
window.location.href = "<?php echo $path; ?>index.php";
} else if (check == 'yes') {
var res1 = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckSMTP');
if (res1 != 'ok') {
if(confirm("<?php echo $mod_strings['LBL_ERROR_SMTP']; ?>")) {
window.location.href = "<?php echo $path; ?>index.php?module=Settings&action=EmailConfig&parenttab=Settings";
return true;
} else {
window.location.href = "<?php echo $path; ?>index.php";
}
} else {
window.location.href = "<?php echo $path; ?>index.php";
}
}
}
});
}
function pleaseWait(status) {
if (status == 'enable') {
VteJS_DialogBox.progress();
} else {
VteJS_DialogBox.hideprogress();
}
}
</script>
</body>
</html>
<?php die; ?>