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

@ -22,195 +22,36 @@ if (VteSession::get('morph_mode') == 'installation') {
} }
//crmv@35153e //crmv@35153e
// first activation /* crmv@130421 */
$first_activation = false; vtlib_toggleModuleAccess('Morphsuit',false);
$saved_morphsuit = getSavedMorphsuit();
if (empty($saved_morphsuit)) { $user_info = Zend_Json::decode($_REQUEST['user_info']);
$first_activation = true;
$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));
} }
global $adb, $table_prefix, $application_unique_key, $default_language; // file dei privilegi
$chiave = $_REQUEST['valida_chiave']; $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');
if (isMorphsuitActive($chiave)) { die('yes');
$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');
?>

View File

@ -3,8 +3,8 @@
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com> * SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
************************************/ ************************************/
/* crmv@130421 */
/* crmv@35153 crmv@54179 crmv@103922 */
// crmv@198545 // crmv@198545
if (!isset($root_directory)) { if (!isset($root_directory)) {
@ -14,6 +14,7 @@ if (!isset($root_directory)) {
require_once('include/utils/utils.php'); require_once('include/utils/utils.php');
// crmv@198545e // crmv@198545e
//crmv@35153 crmv@69514 crmv@69892
$installation_mode = false; $installation_mode = false;
if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') == 'installation') { if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') == 'installation') {
$installation_mode = true; $installation_mode = true;
@ -28,7 +29,7 @@ if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') =
if ($enterprise_mode == 'VTENEXTCE') { // crmv@192073 if ($enterprise_mode == 'VTENEXTCE') { // crmv@192073
// recalc application_unique_key // recalc application_unique_key
$application_unique_key = md5(time() . rand(1,9999999) . md5($root_directory)); $application_unique_key = md5(time() + rand(1,9999999) + md5($root_directory));
$configInc = file_get_contents('config.inc.php'); $configInc = file_get_contents('config.inc.php');
$configInc = preg_replace('/^\$application_unique_key.*$/m', "\$application_unique_key = '{$application_unique_key}';", $configInc); $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); if (is_writable('config.inc.php')) file_put_contents('config.inc.php', $configInc);
@ -42,7 +43,6 @@ if ($_REQUEST['morph_mode'] == 'installation' || VteSession::get('morph_mode') =
$userfile = preg_replace("/'accesskey'\s*=>\s*[^,]+,/", "'accesskey'=>'{$accesskey}',", $userfile); $userfile = preg_replace("/'accesskey'\s*=>\s*[^,]+,/", "'accesskey'=>'{$accesskey}',", $userfile);
if (is_writable($priv_file)) file_put_contents($priv_file, $userfile); if (is_writable($priv_file)) file_put_contents($priv_file, $userfile);
} // crmv@192073 } // crmv@192073
} }
$update_mode = false; $update_mode = false;
if (file_exists('modules/Update/free_changes') && getUserName(1) == 'admin') { if (file_exists('modules/Update/free_changes') && getUserName(1) == 'admin') {
@ -50,23 +50,26 @@ if (file_exists('modules/Update/free_changes') && getUserName(1) == 'admin') {
} elseif (getUserName(1) != 'admin') { } elseif (getUserName(1) != 'admin') {
$username_free = getUserName(1); $username_free = getUserName(1);
} }
if (isFreeVersion()) { //crmv@35153e
$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 = ''; ($installation_mode) ? $path = '../../' : $path = '';
$sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $enterprise_current_version"; 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> <body>
<div id="main-container" class="container"> <div id="main-container" class="container">
<div class="row"> <div class="row">
<div class="col-xs-offset-1 col-xs-10"> <div class="col-xs-offset-2 col-xs-8">
<div id="content" class="col-xs-12"> <div id="content" class="col-xs-12">
<div id="content-cont" class="col-xs-12"> <div id="content-cont" class="col-xs-12">
@ -81,15 +84,12 @@ $sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $ent
<img src="<?php echo $path; ?>themes/logos/vtenext.png" /> <img src="<?php echo $path; ?>themes/logos/vtenext.png" />
</a> </a>
</div> </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>
<div id="config" class="col-xs-12"> <div id="config" class="col-xs-12">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="col-xs-8 col-xs-offset-2"> <div class="col-xs-12">
<?php if ($installation_mode) { ?> <?php if ($installation_mode) { ?>
<form action="SendMorphsuit.php" method="post" id="MorphsuitForm"> <form action="SendMorphsuit.php" method="post" id="MorphsuitForm">
@ -105,66 +105,78 @@ $sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $ent
<table class="table borderless" id="Standard"> <table class="table borderless" id="Standard">
<tr> <tr>
<td align="left"> <td align="left">
<label for="username_std">Username:</label> <label for="username_std"><?php echo getTranslatedString('User Name','Users'); ?></label>
<div class="dvtCellInfo"> <div class="dvtCellInfo">
<input id="username_std" name="username_std" class="small detailedViewTextBox" value="" type="text" /> <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> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left"> <td align="left">
<label for="username_std">Password:</label> <label for="username_std">Password:</label>
<div class="dvtCellInfo"> <div class="dvtCellInfoM">
<input id="password_std" name="password_std" class="small detailedViewTextBox" value="" type="password" /> <input id="password_std" name="password_std" class="small detailedViewTextBox" value="" type="password" />
</div> </div>
</td> </td>
</tr> </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 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> <tr>
<td colspan="2" align="center"> <td colspan="2" align="center">
<div class="dvtCellInfo"> <div class="dvtCellInfo">
<textarea class="small detailedViewTextBox" style="resize:vertical" readonly><?php echo getTranslatedString('LBL_PRIVACY_DESC','Settings'); ?></textarea> <textarea class="small detailedViewTextBox" style="resize:vertical; height:90px" readonly><?php echo getTranslatedString('LBL_PRIVACY_DESC','Settings'); ?></textarea>
</div> </div>
</td> </td>
</tr> </tr>
@ -185,7 +197,10 @@ $sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $ent
<?php if ($_REQUEST['type'] == 'time_expired') { ?> <?php if ($_REQUEST['type'] == 'time_expired') { ?>
<button type="button" onClick="zombieMorph();" class="crmbutton small delete"><?php echo getTranslatedString('LBL_ZOMBIE_MODE','Morphsuit'); ?></button> <button type="button" onClick="zombieMorph();" class="crmbutton small delete"><?php echo getTranslatedString('LBL_ZOMBIE_MODE','Morphsuit'); ?></button>
<?php } ?> <?php } ?>
<!--
<button type="button" onClick="if (validate()) submitStd();" class="crmbutton small edit btn-arrow-right"><?php echo $mod_strings['LBL_MORPHSUIT_NEXT']; ?></button> <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>
@ -205,67 +220,32 @@ $sectionTitle = $mod_strings['LBL_MORPHSUIT_ACTIVATION']." $enterprise_mode $ent
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var currentTab; // crmv@69514
currentTab = 'Standard';
function validate() { var createUser = true;
if (currentTab == 'Free') {
if (!emptyCheck('username_free','Username',getObj('username_free').type)) 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; return false;
if (!emptyCheck('password_free','Password',getObj('password_free').type)) }
return false; var checkPasswValues = {'user_name':'admin','first_name':getObj('first_name').value,'last_name':getObj('last_name').value};
if (!emptyCheck('privacy_flag_free','<?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?> ',getObj('privacy_flag_free').type)) <?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; return false;
}
if (!emptyCheck('privacy_flag_std','<?php echo getTranslatedString('LBL_PRIVACY_FLAG','Settings'); ?> ',getObj('privacy_flag_std').type)) return false;
return true; 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) { function success(response) {
@ -274,21 +254,18 @@ function success(response) {
getObj('checkDataMorphsuit').style.top = '0px'; getObj('checkDataMorphsuit').style.top = '0px';
} }
function zombieMorph() { function submitCreateUser() {
window.location.href = "index.php?module=Morphsuit&action=MorphsuitAjax&file=Zombie";
}
function submitFree() {
pleaseWait('enable'); pleaseWait('enable');
var params = 'tipo_installazione=Free&email='+getObj('email_std').value;
<?php if ($installation_mode) { ?> <?php if ($installation_mode) { ?>
var key = getFile('<?php echo $path; ?>modules/Morphsuit/SendMorphsuit.php?tipo_installazione=Free'); var key = getFile('<?php echo $path; ?>modules/Morphsuit/SendMorphsuit.php?'+params);
<?php } else { ?> <?php } else { ?>
var key = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=SendMorphsuit&tipo_installazione=Free'); var key = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=SendMorphsuit&'+params);
<?php } ?> <?php } ?>
var url = '<?php echo $focus->vteFreeServer; ?>'; var url = '<?php echo $focus->vteFreeServer; ?>';
var params = { var params = {
'method' : 'generateMorphsuit', 'method' : 'generateMorphsuitCommunityUser',
'revision' : '<?php echo $enterprise_current_build; ?>', 'revision' : '<?php echo $enterprise_current_build; ?>',
'subversion' : '<?php echo $enterprise_subversion; ?>', 'subversion' : '<?php echo $enterprise_subversion; ?>',
<?php <?php
@ -303,15 +280,15 @@ function submitFree() {
echo "'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 'key' : key
}; };
jQuery.ajax({ jQuery.ajax({
url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('username_free').value},async:false, url:'<?php echo $path; ?>modules/Morphsuit/MorphParam.php',type:'POST',data:{'value':getObj('email_std').value},async:false,
complete : function(res, status) { params['username'] = res.responseText; } complete : function(res, status) { params['email'] = 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 = ''; var result = '';
jQuery.ajax({ jQuery.ajax({
@ -319,71 +296,49 @@ function submitFree() {
type: 'POST', type: 'POST',
data: params, data: params,
complete : function(res, status) { complete : function(res, status) {
if (status != 'success') { checkMorphsuit();
alert('Connection with VTECRM Network failed ('+status+')'); }
pleaseWait('disable'); });
} else { }
result = res.responseText;
if (result == 'LOGIN_FAILED') { function checkMorphsuit(new_key, user_info) {
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 = { var user_info = {
'username' : getObj('username_free').value, 'username' : getObj('username_std').value,
'password' : getObj('password_free').value, 'password' : getObj('password_std').value,
'email' : result['email'], 'email' : getObj('email_std').value,
'name' : result['name'] 'last_name' : getObj('last_name').value,
'first_name' : getObj('first_name').value
}; };
<?php if ($installation_mode) { ?> <?php if ($installation_mode) { ?>
var url1 = '<?php echo $path; ?>modules/Morphsuit/CheckMorphsuit.php'; var url = '<?php echo $path; ?>modules/Morphsuit/CheckMorphsuit.php';
<?php } else { ?> <?php } else { ?>
var url1 = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckMorphsuit'; var url = 'index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckMorphsuit';
<?php } ?> <?php } ?>
var params1 = { var params = {
'valida_chiave' : new_key,
'user_info' : JSON.stringify(user_info) 'user_info' : JSON.stringify(user_info)
}; };
jQuery.ajax({ jQuery.ajax({
url : url1, url : url,
type: 'POST', type: 'POST',
data: params1, data: params,
complete : function(res1, status1) { complete : function(res1, status1) {
var check = res1.responseText; var check = res1.responseText;
if (check != 'yes') { if (check != 'yes') {
alert('VTECRM Network service fails to create your license (err 5)'); //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') { } else if (check == 'yes') {
var res1 = getFile('<?php echo $path; ?>index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckSMTP'); var res1 = getFile('index.php?module=Morphsuit&action=MorphsuitAjax&file=CheckSMTP');
if (res1 != 'ok') { if (res1 != 'ok') {
// crmv@99315 if(confirm("<?php echo $mod_strings['LBL_ERROR_SMTP']; ?>")) {
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"; window.location.href = "<?php echo $path; ?>index.php?module=Settings&action=EmailConfig&parenttab=Settings";
return true;
} else { } else {
window.location.href = "<?php echo $path; ?>index.php"; window.location.href = "<?php echo $path; ?>index.php";
} }
}); } else {
return;
// crmv@99315e
}
}
window.location.href = "<?php echo $path; ?>index.php"; window.location.href = "<?php echo $path; ?>index.php";
} }
});
}
} }
} }
}); });