@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | <tr> |
| 7 | 7 | <td nowrap class="warning"><?php echo $_lang['udperms_title'] ?><br><small>[(use_udperms)]</small></td> |
| 8 | 8 | <td> |
| 9 | - <?php echo wrap_label($_lang['yes'],form_radio('use_udperms', 1, 'id="udPermsOn"'));?><br />
|
|
| 10 | - <?php echo wrap_label($_lang['no'], form_radio('use_udperms', 0, 'id="udPermsOff"'));?>
|
|
| 9 | + <?php echo wrap_label($_lang['yes'], form_radio('use_udperms', 1, 'id="udPermsOn"')); ?><br />
|
|
| 10 | + <?php echo wrap_label($_lang['no'], form_radio('use_udperms', 0, 'id="udPermsOff"')); ?>
|
|
| 11 | 11 | </td> |
| 12 | 12 | </tr> |
| 13 | 13 | <tr> |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | <tr> |
| 18 | 18 | <td colspan="2"><div class="split"></div></td> |
| 19 | 19 | </tr> |
| 20 | - <tr class="udPerms" <?php echo showHide($use_udperms==1);?>> |
|
| 20 | + <tr class="udPerms" <?php echo showHide($use_udperms == 1); ?>> |
|
| 21 | 21 | <td nowrap class="warning"><?php echo $_lang['udperms_allowroot_title'] ?><br><small>[(udperms_allowroot)]</small></td> |
| 22 | 22 | <td> |
| 23 | - <label><input type="radio" name="udperms_allowroot" value="1" <?php echo $udperms_allowroot=='1' ? 'checked="checked"' : "" ; ?> /> |
|
| 23 | + <label><input type="radio" name="udperms_allowroot" value="1" <?php echo $udperms_allowroot == '1' ? 'checked="checked"' : ""; ?> /> |
|
| 24 | 24 | <?php echo $_lang['yes']?></label><br /> |
| 25 | - <label><input type="radio" name="udperms_allowroot" value="0" <?php echo $udperms_allowroot=='0' ? 'checked="checked"' : "" ; ?> /> |
|
| 25 | + <label><input type="radio" name="udperms_allowroot" value="0" <?php echo $udperms_allowroot == '0' ? 'checked="checked"' : ""; ?> /> |
|
| 26 | 26 | <?php echo $_lang['no']?></label> |
| 27 | 27 | </td> |
| 28 | 28 | </tr> |
| 29 | - <tr class="udPerms" <?php echo showHide($use_udperms==1);?>> |
|
| 29 | + <tr class="udPerms" <?php echo showHide($use_udperms == 1); ?>> |
|
| 30 | 30 | <td width="200"> </td> |
| 31 | 31 | <td class="comment"><?php echo $_lang['udperms_allowroot_message'] ?></td> |
| 32 | 32 | </tr> |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | <tr> |
| 38 | 38 | <td nowrap class="warning"><?php echo $_lang['email_sender_method'] ?><br><small>[(email_sender_method)]</small></td> |
| 39 | 39 | <td> |
| 40 | - <label><input type="radio" name="email_sender_method" value="1" <?php echo $email_sender_method=='1' ? 'checked="checked"' : "" ; ?> /> |
|
| 40 | + <label><input type="radio" name="email_sender_method" value="1" <?php echo $email_sender_method == '1' ? 'checked="checked"' : ""; ?> /> |
|
| 41 | 41 | <?php echo $_lang['auto']?></label><br /> |
| 42 | - <label><input type="radio" name="email_sender_method" value="0" <?php echo $email_sender_method=='0' ? 'checked="checked"' : "" ; ?> /> |
|
| 42 | + <label><input type="radio" name="email_sender_method" value="0" <?php echo $email_sender_method == '0' ? 'checked="checked"' : ""; ?> /> |
|
| 43 | 43 | <?php echo $_lang['use_emailsender']?></label> |
| 44 | 44 | </td> |
| 45 | 45 | </tr> |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | <tr> |
| 56 | 56 | <td nowrap class="warning"><?php echo $_lang['email_method_title'] ?><br><small>[(email_method)]</small></td> |
| 57 | 57 | <td> |
| 58 | - <?php echo wrap_label($_lang['email_method_mail'],form_radio('email_method','mail','id="useMail"'));?><br />
|
|
| 59 | - <?php echo wrap_label($_lang['email_method_smtp'],form_radio('email_method','smtp','id="useSmtp"'));?>
|
|
| 60 | - <div class="smtpRow" <?php echo showHide($email_method=='smtp');?>> |
|
| 61 | - <?php include_once(MODX_MANAGER_PATH . 'actions/mutate_settings/snippet_smtp.inc.php'); ?> |
|
| 58 | + <?php echo wrap_label($_lang['email_method_mail'], form_radio('email_method', 'mail', 'id="useMail"')); ?><br />
|
|
| 59 | + <?php echo wrap_label($_lang['email_method_smtp'], form_radio('email_method', 'smtp', 'id="useSmtp"')); ?>
|
|
| 60 | + <div class="smtpRow" <?php echo showHide($email_method == 'smtp'); ?>> |
|
| 61 | + <?php include_once(MODX_MANAGER_PATH.'actions/mutate_settings/snippet_smtp.inc.php'); ?> |
|
| 62 | 62 | </div> |
| 63 | 63 | </td> |
| 64 | 64 | </tr> |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | <br /> |
| 71 | 71 | <p><?php echo $_lang['update_settings_from_language']; ?></p> |
| 72 | 72 | <select name="reload_emailsubject" id="reload_emailsubject_select" onchange="confirmLangChange(this, 'emailsubject_default', 'emailsubject_field');"> |
| 73 | -<?php echo get_lang_options('emailsubject_default');?>
|
|
| 73 | +<?php echo get_lang_options('emailsubject_default'); ?>
|
|
| 74 | 74 | </select> |
| 75 | 75 | </td> |
| 76 | 76 | <td ><input id="emailsubject_field" name="emailsubject" onchange="documentDirty=true;" type="text" maxlength="255" style="width: 250px;" value="<?php echo $emailsubject; ?>" /> |
| 77 | - <input type="hidden" name="emailsubject_default" id="emailsubject_default_hidden" value="<?php echo addslashes($_lang['emailsubject_default']);?>" /> |
|
| 77 | + <input type="hidden" name="emailsubject_default" id="emailsubject_default_hidden" value="<?php echo addslashes($_lang['emailsubject_default']); ?>" /> |
|
| 78 | 78 | </td> |
| 79 | 79 | </tr> |
| 80 | 80 | <tr> |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | <br /> |
| 90 | 90 | <p><?php echo $_lang['update_settings_from_language']; ?></p> |
| 91 | 91 | <select name="reload_signupemail_message" id="reload_signupemail_message_select" onchange="confirmLangChange(this, 'system_email_signup', 'signupemail_message_textarea');"> |
| 92 | -<?php echo get_lang_options('system_email_signup');?>
|
|
| 92 | +<?php echo get_lang_options('system_email_signup'); ?>
|
|
| 93 | 93 | </select> |
| 94 | 94 | </td> |
| 95 | 95 | <td> <textarea id="signupemail_message_textarea" name="signupemail_message" style="width:100%; height: 120px;"><?php echo $signupemail_message; ?></textarea> |
| 96 | - <input type="hidden" name="system_email_signup_default" id="system_email_signup_hidden" value="<?php echo addslashes($_lang['system_email_signup']);?>" /> |
|
| 96 | + <input type="hidden" name="system_email_signup_default" id="system_email_signup_hidden" value="<?php echo addslashes($_lang['system_email_signup']); ?>" /> |
|
| 97 | 97 | </td> |
| 98 | 98 | </tr> |
| 99 | 99 | <tr> |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | <br /> |
| 109 | 109 | <p><?php echo $_lang['update_settings_from_language']; ?></p> |
| 110 | 110 | <select name="reload_websignupemail_message" id="reload_websignupemail_message_select" onchange="confirmLangChange(this, 'system_email_websignup', 'websignupemail_message_textarea');"> |
| 111 | -<?php echo get_lang_options('system_email_websignup');?>
|
|
| 111 | +<?php echo get_lang_options('system_email_websignup'); ?>
|
|
| 112 | 112 | </select> |
| 113 | 113 | </td> |
| 114 | 114 | <td> <textarea id="websignupemail_message_textarea" name="websignupemail_message" style="width:100%; height: 120px;"><?php echo $websignupemail_message; ?></textarea> |
| 115 | - <input type="hidden" name="system_email_websignup_default" id="system_email_websignup_hidden" value="<?php echo addslashes($_lang['system_email_websignup']);?>" /> |
|
| 115 | + <input type="hidden" name="system_email_websignup_default" id="system_email_websignup_hidden" value="<?php echo addslashes($_lang['system_email_websignup']); ?>" /> |
|
| 116 | 116 | </td> |
| 117 | 117 | </tr> |
| 118 | 118 | <tr> |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | <br /> |
| 128 | 128 | <p><?php echo $_lang['update_settings_from_language']; ?></p> |
| 129 | 129 | <select name="reload_system_email_webreminder_message" id="reload_system_email_webreminder_select" onchange="confirmLangChange(this, 'system_email_webreminder', 'system_email_webreminder_textarea');"> |
| 130 | -<?php echo get_lang_options('system_email_webreminder');?>
|
|
| 130 | +<?php echo get_lang_options('system_email_webreminder'); ?>
|
|
| 131 | 131 | </select> |
| 132 | 132 | </td> |
| 133 | 133 | <td> <textarea id="system_email_webreminder_textarea" name="webpwdreminder_message" style="width:100%; height: 120px;"><?php echo $webpwdreminder_message; ?></textarea> |
| 134 | - <input type="hidden" name="system_email_webreminder_default" id="system_email_webreminder_hidden" value="<?php echo addslashes($_lang['system_email_webreminder']);?>" /> |
|
| 134 | + <input type="hidden" name="system_email_webreminder_default" id="system_email_webreminder_hidden" value="<?php echo addslashes($_lang['system_email_webreminder']); ?>" /> |
|
| 135 | 135 | </td> |
| 136 | 136 | </tr> |
| 137 | 137 | <tr> |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | <?php |
| 144 | 144 | // invoke OnUserSettingsRender event |
| 145 | 145 | $evtOut = $modx->invokeEvent('OnUserSettingsRender');
|
| 146 | - if(is_array($evtOut)) echo implode("",$evtOut);
|
|
| 146 | + if (is_array($evtOut)) echo implode("", $evtOut);
|
|
| 147 | 147 | ?> |
| 148 | 148 | </td> |
| 149 | 149 | </tr> |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | <tr> |
| 154 | 154 | <td nowrap class="warning" valign="top"><?php echo $_lang['allow_multiple_emails_title'] ?><br><small>[(allow_multiple_emails)]</small></td> |
| 155 | 155 | <td> |
| 156 | - <?php echo wrap_label($_lang['yes'],form_radio('allow_multiple_emails','1'));?><br />
|
|
| 157 | - <?php echo wrap_label($_lang['no'], form_radio('allow_multiple_emails','0'));?>
|
|
| 156 | + <?php echo wrap_label($_lang['yes'], form_radio('allow_multiple_emails', '1')); ?><br />
|
|
| 157 | + <?php echo wrap_label($_lang['no'], form_radio('allow_multiple_emails', '0')); ?>
|
|
| 158 | 158 | </td> |
| 159 | 159 | </tr> |
| 160 | 160 | <tr> |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('save_web_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | 14 | foreach($input as $k => $v) { |
| 15 | - if($k !== 'comment') { |
|
| 16 | - $v = sanitize($v); |
|
| 17 | - } |
|
| 18 | - $input[$k] = $v; |
|
| 15 | + if($k !== 'comment') { |
|
| 16 | + $v = sanitize($v); |
|
| 17 | + } |
|
| 18 | + $input[$k] = $v; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = (int)$input['id']; |
@@ -51,82 +51,82 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | - $limit = $modx->db->getValue($rs); |
|
| 75 | - if($limit > 0) { |
|
| 76 | - webAlertAndQuit("Email is already in use!"); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // generate a new password for this user |
|
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 83 | - webAlertAndQuit("Password is too short!"); |
|
| 84 | - } else { |
|
| 85 | - $newpassword = $specifiedpassword; |
|
| 86 | - } |
|
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 90 | - $newpassword = generate_password(8); |
|
| 91 | - } else { |
|
| 92 | - webAlertAndQuit("No password generation method specified!"); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // invoke OnBeforeWUsrFormSave event |
|
| 96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | - "mode" => "new", |
|
| 98 | - )); |
|
| 99 | - |
|
| 100 | - // create the user account |
|
| 101 | - $field = array(); |
|
| 102 | - $field['username'] = $esc_newusername; |
|
| 103 | - $field['password'] = md5($newpassword); |
|
| 104 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | - |
|
| 106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | - $field = $modx->db->escape($field); |
|
| 108 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | - |
|
| 110 | - // Save User Settings |
|
| 111 | - saveUserSettings($internalKey); |
|
| 112 | - |
|
| 113 | - // Set the item name for logger |
|
| 114 | - $_SESSION['itemname'] = $newusername; |
|
| 115 | - |
|
| 116 | - /*******************************************************************************/ |
|
| 117 | - // put the user in the user_groups he/ she should be in |
|
| 118 | - // first, check that up_perms are switched on! |
|
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | - $f = array(); |
|
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | - $f['webuser'] = $internalKey; |
|
| 125 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - // end of user_groups stuff! |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | + $limit = $modx->db->getValue($rs); |
|
| 75 | + if($limit > 0) { |
|
| 76 | + webAlertAndQuit("Email is already in use!"); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // generate a new password for this user |
|
| 81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if(strlen($specifiedpassword) < 6) { |
|
| 83 | + webAlertAndQuit("Password is too short!"); |
|
| 84 | + } else { |
|
| 85 | + $newpassword = $specifiedpassword; |
|
| 86 | + } |
|
| 87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | + } elseif($passwordgenmethod == 'g') { |
|
| 90 | + $newpassword = generate_password(8); |
|
| 91 | + } else { |
|
| 92 | + webAlertAndQuit("No password generation method specified!"); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // invoke OnBeforeWUsrFormSave event |
|
| 96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | + "mode" => "new", |
|
| 98 | + )); |
|
| 99 | + |
|
| 100 | + // create the user account |
|
| 101 | + $field = array(); |
|
| 102 | + $field['username'] = $esc_newusername; |
|
| 103 | + $field['password'] = md5($newpassword); |
|
| 104 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | + |
|
| 106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | + $field = $modx->db->escape($field); |
|
| 108 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | + |
|
| 110 | + // Save User Settings |
|
| 111 | + saveUserSettings($internalKey); |
|
| 112 | + |
|
| 113 | + // Set the item name for logger |
|
| 114 | + $_SESSION['itemname'] = $newusername; |
|
| 115 | + |
|
| 116 | + /*******************************************************************************/ |
|
| 117 | + // put the user in the user_groups he/ she should be in |
|
| 118 | + // first, check that up_perms are switched on! |
|
| 119 | + if($use_udperms == 1) { |
|
| 120 | + if(!empty($user_groups)) { |
|
| 121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | + $f = array(); |
|
| 123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | + $f['webuser'] = $internalKey; |
|
| 125 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + // end of user_groups stuff! |
|
| 130 | 130 | |
| 131 | 131 | // invoke OnWebSaveUser event |
| 132 | 132 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -144,26 +144,26 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 148 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | - if($input['stay'] != '') { |
|
| 150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | - header($header); |
|
| 153 | - } else { |
|
| 154 | - $header = "Location: index.php?a=99&r=2"; |
|
| 155 | - header($header); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - } else { |
|
| 162 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - include_once "header.inc.php"; |
|
| 166 | - ?> |
|
| 147 | + if($passwordnotifymethod == 'e') { |
|
| 148 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | + if($input['stay'] != '') { |
|
| 150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | + header($header); |
|
| 153 | + } else { |
|
| 154 | + $header = "Location: index.php?a=99&r=2"; |
|
| 155 | + header($header); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + } else { |
|
| 162 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + include_once "header.inc.php"; |
|
| 166 | + ?> |
|
| 167 | 167 | |
| 168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 169 | 169 | |
@@ -185,86 +185,86 @@ discard block |
||
| 185 | 185 | </div> |
| 186 | 186 | <?php |
| 187 | 187 | |
| 188 | - include_once "footer.inc.php"; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - case '88' : // edit user |
|
| 192 | - // generate a new password for this user |
|
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 196 | - webAlertAndQuit("Password is too short!"); |
|
| 197 | - } else { |
|
| 198 | - $newpassword = $specifiedpassword; |
|
| 199 | - } |
|
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 203 | - $newpassword = generate_password(8); |
|
| 204 | - } else { |
|
| 205 | - webAlertAndQuit("No password generation method specified!"); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 209 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // check if the username already exist |
|
| 213 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | - $limit = $modx->db->getValue($rs); |
|
| 215 | - if($limit > 0) { |
|
| 216 | - webAlertAndQuit("User name is already in use!"); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // check if the email address already exists |
|
| 220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | - $limit = $modx->db->getValue($rs); |
|
| 223 | - if($limit > 0) { |
|
| 224 | - webAlertAndQuit("Email is already in use!"); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // invoke OnBeforeWUsrFormSave event |
|
| 229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | - "mode" => "upd", |
|
| 231 | - "id" => $id |
|
| 232 | - )); |
|
| 233 | - |
|
| 234 | - // update user name and password |
|
| 235 | - $field = array(); |
|
| 236 | - $field['username'] = $esc_newusername; |
|
| 237 | - if($genpassword == 1) { |
|
| 238 | - $field['password'] = md5($newpassword); |
|
| 239 | - } |
|
| 240 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | - $field = $modx->db->escape($field); |
|
| 243 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | - |
|
| 245 | - // Save User Settings |
|
| 246 | - saveUserSettings($id); |
|
| 247 | - |
|
| 248 | - // Set the item name for logger |
|
| 249 | - $_SESSION['itemname'] = $newusername; |
|
| 250 | - |
|
| 251 | - /*******************************************************************************/ |
|
| 252 | - // put the user in the user_groups he/ she should be in |
|
| 253 | - // first, check that up_perms are switched on! |
|
| 254 | - if($use_udperms == 1) { |
|
| 255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | - $field = array(); |
|
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | - $field['webuser'] = $id; |
|
| 262 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - // end of user_groups stuff! |
|
| 267 | - /*******************************************************************************/ |
|
| 188 | + include_once "footer.inc.php"; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + case '88' : // edit user |
|
| 192 | + // generate a new password for this user |
|
| 193 | + if($genpassword == 1) { |
|
| 194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if(strlen($specifiedpassword) < 6) { |
|
| 196 | + webAlertAndQuit("Password is too short!"); |
|
| 197 | + } else { |
|
| 198 | + $newpassword = $specifiedpassword; |
|
| 199 | + } |
|
| 200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | + } elseif($passwordgenmethod == 'g') { |
|
| 203 | + $newpassword = generate_password(8); |
|
| 204 | + } else { |
|
| 205 | + webAlertAndQuit("No password generation method specified!"); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + if($passwordnotifymethod == 'e') { |
|
| 209 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // check if the username already exist |
|
| 213 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | + $limit = $modx->db->getValue($rs); |
|
| 215 | + if($limit > 0) { |
|
| 216 | + webAlertAndQuit("User name is already in use!"); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // check if the email address already exists |
|
| 220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | + $limit = $modx->db->getValue($rs); |
|
| 223 | + if($limit > 0) { |
|
| 224 | + webAlertAndQuit("Email is already in use!"); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // invoke OnBeforeWUsrFormSave event |
|
| 229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | + "mode" => "upd", |
|
| 231 | + "id" => $id |
|
| 232 | + )); |
|
| 233 | + |
|
| 234 | + // update user name and password |
|
| 235 | + $field = array(); |
|
| 236 | + $field['username'] = $esc_newusername; |
|
| 237 | + if($genpassword == 1) { |
|
| 238 | + $field['password'] = md5($newpassword); |
|
| 239 | + } |
|
| 240 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | + $field = $modx->db->escape($field); |
|
| 243 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | + |
|
| 245 | + // Save User Settings |
|
| 246 | + saveUserSettings($id); |
|
| 247 | + |
|
| 248 | + // Set the item name for logger |
|
| 249 | + $_SESSION['itemname'] = $newusername; |
|
| 250 | + |
|
| 251 | + /*******************************************************************************/ |
|
| 252 | + // put the user in the user_groups he/ she should be in |
|
| 253 | + // first, check that up_perms are switched on! |
|
| 254 | + if($use_udperms == 1) { |
|
| 255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | + if(!empty($user_groups)) { |
|
| 258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | + $field = array(); |
|
| 260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | + $field['webuser'] = $id; |
|
| 262 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + // end of user_groups stuff! |
|
| 267 | + /*******************************************************************************/ |
|
| 268 | 268 | |
| 269 | 269 | // invoke OnWebSaveUser event |
| 270 | 270 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | - } else { |
|
| 301 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | - } |
|
| 296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if($input['stay'] != '') { |
|
| 298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | + } else { |
|
| 301 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - include_once "header.inc.php"; |
|
| 305 | - ?> |
|
| 304 | + include_once "header.inc.php"; |
|
| 305 | + ?> |
|
| 306 | 306 | |
| 307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 308 | 308 | |
@@ -322,20 +322,20 @@ discard block |
||
| 322 | 322 | </div> |
| 323 | 323 | <?php |
| 324 | 324 | |
| 325 | - include_once "footer.inc.php"; |
|
| 326 | - } else { |
|
| 327 | - if($input['stay'] != '') { |
|
| 328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | - header($header); |
|
| 331 | - } else { |
|
| 332 | - $header = "Location: index.php?a=99&r=2"; |
|
| 333 | - header($header); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - default : |
|
| 338 | - webAlertAndQuit("No operation set in request."); |
|
| 325 | + include_once "footer.inc.php"; |
|
| 326 | + } else { |
|
| 327 | + if($input['stay'] != '') { |
|
| 328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | + header($header); |
|
| 331 | + } else { |
|
| 332 | + $header = "Location: index.php?a=99&r=2"; |
|
| 333 | + header($header); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + default : |
|
| 338 | + webAlertAndQuit("No operation set in request."); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -345,14 +345,14 @@ discard block |
||
| 345 | 345 | * @return string |
| 346 | 346 | */ |
| 347 | 347 | function save_user_quoted_printable($string) { |
| 348 | - $crlf = "\n"; |
|
| 349 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 350 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 351 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 352 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 353 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 354 | - $string = preg_replace($f, $r, $string); |
|
| 355 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 348 | + $crlf = "\n"; |
|
| 349 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 350 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 351 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 352 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 353 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 354 | + $string = preg_replace($f, $r, $string); |
|
| 355 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -364,94 +364,94 @@ discard block |
||
| 364 | 364 | * @param string $ufn |
| 365 | 365 | */ |
| 366 | 366 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 367 | - global $modx, $_lang, $websignupemail_message; |
|
| 368 | - global $emailsubject, $emailsender; |
|
| 369 | - global $site_name, $site_url; |
|
| 370 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 371 | - // replace placeholders |
|
| 372 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 373 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 374 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 375 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 376 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 377 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 378 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
| 379 | - |
|
| 380 | - $param = array(); |
|
| 381 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 382 | - $param['subject'] = $emailsubject; |
|
| 383 | - $param['body'] = $message; |
|
| 384 | - $param['to'] = $email; |
|
| 385 | - $param['type'] = 'text'; |
|
| 386 | - $rs = $modx->sendmail($param); |
|
| 387 | - if(!$rs) { |
|
| 388 | - $modx->manager->saveFormValues(); |
|
| 389 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 390 | - } |
|
| 367 | + global $modx, $_lang, $websignupemail_message; |
|
| 368 | + global $emailsubject, $emailsender; |
|
| 369 | + global $site_name, $site_url; |
|
| 370 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 371 | + // replace placeholders |
|
| 372 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 373 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 374 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 375 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 376 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 377 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 378 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
| 379 | + |
|
| 380 | + $param = array(); |
|
| 381 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 382 | + $param['subject'] = $emailsubject; |
|
| 383 | + $param['body'] = $message; |
|
| 384 | + $param['to'] = $email; |
|
| 385 | + $param['type'] = 'text'; |
|
| 386 | + $rs = $modx->sendmail($param); |
|
| 387 | + if(!$rs) { |
|
| 388 | + $modx->manager->saveFormValues(); |
|
| 389 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // Save User Settings |
| 394 | 394 | function saveUserSettings($id) { |
| 395 | - global $modx; |
|
| 396 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 397 | - |
|
| 398 | - $settings = array( |
|
| 399 | - "login_home", |
|
| 400 | - "allowed_ip", |
|
| 401 | - "allowed_days" |
|
| 402 | - ); |
|
| 403 | - |
|
| 404 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 405 | - |
|
| 406 | - foreach($settings as $n) { |
|
| 407 | - $vl = $_POST[$n]; |
|
| 408 | - if(is_array($vl)) { |
|
| 409 | - $vl = implode(",", $vl); |
|
| 410 | - } |
|
| 411 | - if($vl != '') { |
|
| 412 | - $f = array(); |
|
| 413 | - $f['webuser'] = $id; |
|
| 414 | - $f['setting_name'] = $n; |
|
| 415 | - $f['setting_value'] = $vl; |
|
| 416 | - $f = $modx->db->escape($f); |
|
| 417 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
| 418 | - } |
|
| 419 | - } |
|
| 395 | + global $modx; |
|
| 396 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 397 | + |
|
| 398 | + $settings = array( |
|
| 399 | + "login_home", |
|
| 400 | + "allowed_ip", |
|
| 401 | + "allowed_days" |
|
| 402 | + ); |
|
| 403 | + |
|
| 404 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 405 | + |
|
| 406 | + foreach($settings as $n) { |
|
| 407 | + $vl = $_POST[$n]; |
|
| 408 | + if(is_array($vl)) { |
|
| 409 | + $vl = implode(",", $vl); |
|
| 410 | + } |
|
| 411 | + if($vl != '') { |
|
| 412 | + $f = array(); |
|
| 413 | + $f['webuser'] = $id; |
|
| 414 | + $f['setting_name'] = $n; |
|
| 415 | + $f['setting_value'] = $vl; |
|
| 416 | + $f = $modx->db->escape($f); |
|
| 417 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Web alert - sends an alert to web browser |
| 423 | 423 | function webAlertAndQuit($msg) { |
| 424 | - global $id, $modx; |
|
| 425 | - $mode = $_POST['mode']; |
|
| 426 | - $modx->manager->saveFormValues($mode); |
|
| 427 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 424 | + global $id, $modx; |
|
| 425 | + $mode = $_POST['mode']; |
|
| 426 | + $modx->manager->saveFormValues($mode); |
|
| 427 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Generate password |
| 431 | 431 | function generate_password($length = 10) { |
| 432 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 433 | - $ps_len = strlen($allowable_characters); |
|
| 434 | - mt_srand((double) microtime() * 1000000); |
|
| 435 | - $pass = ""; |
|
| 436 | - for($i = 0; $i < $length; $i++) { |
|
| 437 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 438 | - } |
|
| 439 | - return $pass; |
|
| 432 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 433 | + $ps_len = strlen($allowable_characters); |
|
| 434 | + mt_srand((double) microtime() * 1000000); |
|
| 435 | + $pass = ""; |
|
| 436 | + for($i = 0; $i < $length; $i++) { |
|
| 437 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 438 | + } |
|
| 439 | + return $pass; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | function sanitize($str = '', $safecount = 0) { |
| 443 | - global $modx; |
|
| 444 | - $safecount++; |
|
| 445 | - if(1000 < $safecount) { |
|
| 446 | - exit("error too many loops '{$safecount}'"); |
|
| 447 | - } |
|
| 448 | - if(is_array($str)) { |
|
| 449 | - foreach($str as $i => $v) { |
|
| 450 | - $str[$i] = sanitize($v, $safecount); |
|
| 451 | - } |
|
| 452 | - } else { |
|
| 453 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
| 454 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 455 | - } |
|
| 456 | - return $str; |
|
| 443 | + global $modx; |
|
| 444 | + $safecount++; |
|
| 445 | + if(1000 < $safecount) { |
|
| 446 | + exit("error too many loops '{$safecount}'"); |
|
| 447 | + } |
|
| 448 | + if(is_array($str)) { |
|
| 449 | + foreach($str as $i => $v) { |
|
| 450 | + $str[$i] = sanitize($v, $safecount); |
|
| 451 | + } |
|
| 452 | + } else { |
|
| 453 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
| 454 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 455 | + } |
|
| 456 | + return $str; |
|
| 457 | 457 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('save_web_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_web_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | $tbl_web_groups = $modx->getFullTableName('web_groups'); |
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | -foreach($input as $k => $v) { |
|
| 15 | - if($k !== 'comment') { |
|
| 14 | +foreach ($input as $k => $v) { |
|
| 15 | + if ($k !== 'comment') { |
|
| 16 | 16 | $v = sanitize($v); |
| 17 | 17 | } |
| 18 | 18 | $input[$k] = $v; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$id = (int)$input['id']; |
|
| 21 | +$id = (int) $input['id']; |
|
| 22 | 22 | $oldusername = $input['oldusername']; |
| 23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 24 | 24 | $esc_newusername = $modx->db->escape($newusername); |
@@ -50,21 +50,21 @@ discard block |
||
| 50 | 50 | $user_groups = $input['user_groups']; |
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 54 | 54 | webAlertAndQuit("Password typed is mismatched"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 58 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 59 | 59 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -switch($input['mode']) { |
|
| 62 | +switch ($input['mode']) { |
|
| 63 | 63 | case '87' : // new user |
| 64 | 64 | // check if this user name already exist |
| 65 | 65 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
| 66 | 66 | $limit = $modx->db->getValue($rs); |
| 67 | - if($limit > 0) { |
|
| 67 | + if ($limit > 0) { |
|
| 68 | 68 | webAlertAndQuit("User name is already in use!"); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,21 +72,21 @@ discard block |
||
| 72 | 72 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 73 | 73 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
| 74 | 74 | $limit = $modx->db->getValue($rs); |
| 75 | - if($limit > 0) { |
|
| 75 | + if ($limit > 0) { |
|
| 76 | 76 | webAlertAndQuit("Email is already in use!"); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // generate a new password for this user |
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if (strlen($specifiedpassword) < 6) { |
|
| 83 | 83 | webAlertAndQuit("Password is too short!"); |
| 84 | 84 | } else { |
| 85 | 85 | $newpassword = $specifiedpassword; |
| 86 | 86 | } |
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 87 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | 88 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 89 | + } elseif ($passwordgenmethod == 'g') { |
|
| 90 | 90 | $newpassword = generate_password(8); |
| 91 | 91 | } else { |
| 92 | 92 | webAlertAndQuit("No password generation method specified!"); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | /*******************************************************************************/ |
| 117 | 117 | // put the user in the user_groups he/ she should be in |
| 118 | 118 | // first, check that up_perms are switched on! |
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 119 | + if ($use_udperms == 1) { |
|
| 120 | + if (!empty($user_groups)) { |
|
| 121 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | 122 | $f = array(); |
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 123 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
| 124 | 124 | $f['webuser'] = $internalKey; |
| 125 | 125 | $modx->db->insert($f, $tbl_web_groups); |
| 126 | 126 | } |
@@ -144,20 +144,20 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 147 | + if ($passwordnotifymethod == 'e') { |
|
| 148 | 148 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 149 | - if($input['stay'] != '') { |
|
| 149 | + if ($input['stay'] != '') { |
|
| 150 | 150 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 152 | 152 | header($header); |
| 153 | 153 | } else { |
| 154 | 154 | $header = "Location: index.php?a=99&r=2"; |
| 155 | 155 | header($header); |
| 156 | 156 | } |
| 157 | 157 | } else { |
| 158 | - if($input['stay'] != '') { |
|
| 158 | + if ($input['stay'] != '') { |
|
| 159 | 159 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 161 | 161 | } else { |
| 162 | 162 | $stayUrl = "index.php?a=99&r=2"; |
| 163 | 163 | } |
@@ -190,29 +190,29 @@ discard block |
||
| 190 | 190 | break; |
| 191 | 191 | case '88' : // edit user |
| 192 | 192 | // generate a new password for this user |
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 193 | + if ($genpassword == 1) { |
|
| 194 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if (strlen($specifiedpassword) < 6) { |
|
| 196 | 196 | webAlertAndQuit("Password is too short!"); |
| 197 | 197 | } else { |
| 198 | 198 | $newpassword = $specifiedpassword; |
| 199 | 199 | } |
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 200 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | 201 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 202 | + } elseif ($passwordgenmethod == 'g') { |
|
| 203 | 203 | $newpassword = generate_password(8); |
| 204 | 204 | } else { |
| 205 | 205 | webAlertAndQuit("No password generation method specified!"); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 208 | + if ($passwordnotifymethod == 'e') { |
|
| 209 | 209 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // check if the username already exist |
| 213 | 213 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
| 214 | 214 | $limit = $modx->db->getValue($rs); |
| 215 | - if($limit > 0) { |
|
| 215 | + if ($limit > 0) { |
|
| 216 | 216 | webAlertAndQuit("User name is already in use!"); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 221 | 221 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
| 222 | 222 | $limit = $modx->db->getValue($rs); |
| 223 | - if($limit > 0) { |
|
| 223 | + if ($limit > 0) { |
|
| 224 | 224 | webAlertAndQuit("Email is already in use!"); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // update user name and password |
| 235 | 235 | $field = array(); |
| 236 | 236 | $field['username'] = $esc_newusername; |
| 237 | - if($genpassword == 1) { |
|
| 237 | + if ($genpassword == 1) { |
|
| 238 | 238 | $field['password'] = md5($newpassword); |
| 239 | 239 | } |
| 240 | 240 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | /*******************************************************************************/ |
| 252 | 252 | // put the user in the user_groups he/ she should be in |
| 253 | 253 | // first, check that up_perms are switched on! |
| 254 | - if($use_udperms == 1) { |
|
| 254 | + if ($use_udperms == 1) { |
|
| 255 | 255 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 256 | 256 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 257 | + if (!empty($user_groups)) { |
|
| 258 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | 259 | $field = array(); |
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 260 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
| 261 | 261 | $field['webuser'] = $id; |
| 262 | 262 | $modx->db->insert($field, $tbl_web_groups); |
| 263 | 263 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | )); |
| 280 | 280 | |
| 281 | 281 | // invoke OnWebChangePassword event |
| 282 | - if($genpassword == 1) { |
|
| 282 | + if ($genpassword == 1) { |
|
| 283 | 283 | $modx->invokeEvent("OnWebChangePassword", array( |
| 284 | 284 | "userid" => $id, |
| 285 | 285 | "username" => $newusername, |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 296 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if ($input['stay'] != '') { |
|
| 298 | 298 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 300 | 300 | } else { |
| 301 | 301 | $stayUrl = "index.php?a=99&r=2"; |
| 302 | 302 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | include_once "footer.inc.php"; |
| 326 | 326 | } else { |
| 327 | - if($input['stay'] != '') { |
|
| 327 | + if ($input['stay'] != '') { |
|
| 328 | 328 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 330 | 330 | header($header); |
| 331 | 331 | } else { |
| 332 | 332 | $header = "Location: index.php?a=99&r=2"; |
@@ -344,15 +344,15 @@ discard block |
||
| 344 | 344 | * @param string $string |
| 345 | 345 | * @return string |
| 346 | 346 | */ |
| 347 | -function save_user_quoted_printable($string) { |
|
| 347 | +function save_user_quoted_printable($string){ |
|
| 348 | 348 | $crlf = "\n"; |
| 349 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 349 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
| 350 | 350 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
| 351 | 351 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
| 352 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 353 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 352 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
| 353 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
| 354 | 354 | $string = preg_replace($f, $r, $string); |
| 355 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 355 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param string $pwd |
| 364 | 364 | * @param string $ufn |
| 365 | 365 | */ |
| 366 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 366 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 367 | 367 | global $modx, $_lang, $websignupemail_message; |
| 368 | 368 | global $emailsubject, $emailsender; |
| 369 | 369 | global $site_name, $site_url; |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | $param['to'] = $email; |
| 385 | 385 | $param['type'] = 'text'; |
| 386 | 386 | $rs = $modx->sendmail($param); |
| 387 | - if(!$rs) { |
|
| 387 | + if (!$rs) { |
|
| 388 | 388 | $modx->manager->saveFormValues(); |
| 389 | 389 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // Save User Settings |
| 394 | -function saveUserSettings($id) { |
|
| 394 | +function saveUserSettings($id){ |
|
| 395 | 395 | global $modx; |
| 396 | 396 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 397 | 397 | |
@@ -403,12 +403,12 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
| 405 | 405 | |
| 406 | - foreach($settings as $n) { |
|
| 406 | + foreach ($settings as $n) { |
|
| 407 | 407 | $vl = $_POST[$n]; |
| 408 | - if(is_array($vl)) { |
|
| 408 | + if (is_array($vl)) { |
|
| 409 | 409 | $vl = implode(",", $vl); |
| 410 | 410 | } |
| 411 | - if($vl != '') { |
|
| 411 | + if ($vl != '') { |
|
| 412 | 412 | $f = array(); |
| 413 | 413 | $f['webuser'] = $id; |
| 414 | 414 | $f['setting_name'] = $n; |
@@ -420,33 +420,33 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Web alert - sends an alert to web browser |
| 423 | -function webAlertAndQuit($msg) { |
|
| 423 | +function webAlertAndQuit($msg){ |
|
| 424 | 424 | global $id, $modx; |
| 425 | 425 | $mode = $_POST['mode']; |
| 426 | 426 | $modx->manager->saveFormValues($mode); |
| 427 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 427 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Generate password |
| 431 | -function generate_password($length = 10) { |
|
| 431 | +function generate_password($length = 10){ |
|
| 432 | 432 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 433 | 433 | $ps_len = strlen($allowable_characters); |
| 434 | 434 | mt_srand((double) microtime() * 1000000); |
| 435 | 435 | $pass = ""; |
| 436 | - for($i = 0; $i < $length; $i++) { |
|
| 436 | + for ($i = 0; $i < $length; $i++) { |
|
| 437 | 437 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 438 | 438 | } |
| 439 | 439 | return $pass; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | -function sanitize($str = '', $safecount = 0) { |
|
| 442 | +function sanitize($str = '', $safecount = 0){ |
|
| 443 | 443 | global $modx; |
| 444 | 444 | $safecount++; |
| 445 | - if(1000 < $safecount) { |
|
| 445 | + if (1000 < $safecount) { |
|
| 446 | 446 | exit("error too many loops '{$safecount}'"); |
| 447 | 447 | } |
| 448 | - if(is_array($str)) { |
|
| 449 | - foreach($str as $i => $v) { |
|
| 448 | + if (is_array($str)) { |
|
| 449 | + foreach ($str as $i => $v) { |
|
| 450 | 450 | $str[$i] = sanitize($v, $safecount); |
| 451 | 451 | } |
| 452 | 452 | } else { |