Changeset 3180156
- Timestamp:
- 11/01/2024 08:10:56 PM (16 months ago)
- Location:
- ejabberd-account-tools/trunk/includes
- Files:
-
- 9 edited
-
admin-settings.php (modified) (1 diff)
-
admin-tools.php (modified) (17 diffs)
-
captcha.php (modified) (1 diff)
-
change_email.php (modified) (2 diffs)
-
delete_account.php (modified) (6 diffs)
-
functions.php (modified) (8 diffs)
-
register.php (modified) (4 diffs)
-
reset_password.php (modified) (7 diffs)
-
webpresence.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ejabberd-account-tools/trunk/includes/admin-settings.php
r3176434 r3180156 571 571 $message = __('The cache has been successfully cleared.', 'ejabberd-account-tools'); 572 572 // Return response 573 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));573 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 574 574 } -
ejabberd-account-tools/trunk/includes/admin-tools.php
r3176128 r3180156 72 72 <th><?php _e('JID', 'ejabberd-account-tools'); ?></th> 73 73 <td> 74 <input name="jid" id="jid" type="text" size="40" value="<?php echo stripslashes_deep($_POST['jid']); ?>" />74 <input name="jid" id="jid" type="text" size="40" value="<?php echo isset($_POST['jid']) ? stripslashes_deep($_POST['jid']) : ''; ?>" /> 75 75 </td> 76 76 </tr> … … 78 78 <th><?php _e('Email', 'ejabberd-account-tools'); ?></th> 79 79 <td> 80 <input name="email" id="email" type="text" size="40" value="<?php echo stripslashes_deep($_POST['email']); ?>" />80 <input name="email" id="email" type="text" size="40" value="<?php echo isset($_POST['email']) ? stripslashes_deep($_POST['email']) : ''; ?>" /> 81 81 </td> 82 82 </tr> … … 101 101 <th><?php _e('JID', 'ejabberd-account-tools'); ?></th> 102 102 <td> 103 <input name="jid" id="jid" type="text" size="40" value="<?php echo stripslashes_deep($_POST['jid']); ?>" />103 <input name="jid" id="jid" type="text" size="40" value="<?php echo isset($_POST['jid']) ? stripslashes_deep($_POST['jid']) : ''; ?>" /> 104 104 </td> 105 105 </tr> … … 107 107 <th><?php _e('Reason', 'ejabberd-account-tools'); ?></th> 108 108 <td> 109 <input name="reason" id="reason" type="text" size="40" value="<?php echo stripslashes_deep($_POST['reason']); ?>" />109 <input name="reason" id="reason" type="text" size="40" value="<?php echo isset($_POST['reason']) ? stripslashes_deep($_POST['reason']) : ''; ?>" /> 110 110 </td> 111 111 </tr> … … 113 113 <th><?php _e('Ban date', 'ejabberd-account-tools'); ?></th> 114 114 <td> 115 <input name="bandate" id="bandate" type="text" size="40" value="<?php echo stripslashes_deep($_POST['bandate']); ?>" disabled/>115 <input name="bandate" id="bandate" type="text" size="40" value="<?php echo isset($_POST['bandate']) ? stripslashes_deep($_POST['bandate']) : ''; ?>" disabled/> 116 116 </td> 117 117 </tr> … … 137 137 <th><?php _e('IP', 'ejabberd-account-tools'); ?></th> 138 138 <td> 139 <input name="ip" id="ip" type="text" size="40" value="<?php echo stripslashes_deep($_POST['ip']); ?>" />139 <input name="ip" id="ip" type="text" size="40" value="<?php echo isset($_POST['ip']) ? stripslashes_deep($_POST['ip']) : ''; ?>" /> 140 140 </td> 141 141 </tr> … … 158 158 <th><?php _e('JID', 'ejabberd-account-tools'); ?></th> 159 159 <td> 160 <input name="jid" id="jid" type="text" size="40" value="<?php echo stripslashes_deep($_POST['jid']); ?>" />160 <input name="jid" id="jid" type="text" size="40" value="<?php echo isset($_POST['jid']) ? stripslashes_deep($_POST['jid']) : ''; ?>" /> 161 161 </td> 162 162 </tr> … … 164 164 <th><?php _e('Subject', 'ejabberd-account-tools'); ?></th> 165 165 <td> 166 <input name="subject" id="subject" type="text" size="40" value="<?php echo stripslashes_deep($_POST['subject']); ?>" />166 <input name="subject" id="subject" type="text" size="40" value="<?php echo isset($_POST['subject']) ? stripslashes_deep($_POST['subject']) : ''; ?>" /> 167 167 </td> 168 168 </tr> … … 170 170 <th><?php _e('Body', 'ejabberd-account-tools'); ?></th> 171 171 <td> 172 <textarea name="body" id="body" type="text" cols="50" rows="5" /><?php echo stripslashes_deep($_POST['body']); ?></textarea>172 <textarea name="body" id="body" type="text" cols="50" rows="5" /><?php echo isset($_POST['body']) ? stripslashes_deep($_POST['body']) : ''; ?></textarea> 173 173 </td> 174 174 </tr> … … 283 283 } 284 284 // Return response 285 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));285 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 286 286 } 287 287 … … 335 335 } 336 336 // Return response 337 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));337 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 338 338 } 339 339 … … 377 377 } 378 378 // Return response 379 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));379 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 380 380 } 381 381 … … 419 419 } 420 420 // Return response 421 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));421 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 422 422 } 423 423 … … 451 451 // Ban details 452 452 else if($response['code'] == 0) { 453 $_POST['reason'] = json_decode($response['body'])->reason;454 $_POST['bandate'] = json_decode($response['body'])->bandate;453 $_POST['reason'] = isset(json_decode($response['body'])->reason) ? json_decode($response['body'])->reason : ''; 454 $_POST['bandate'] = isset(json_decode($response['body'])->bandate) ? json_decode($response['body'])->bandate : ''; 455 455 $status = 'success'; 456 456 $message = __('Ban details obtained successfully.', 'ejabberd-account-tools'); … … 463 463 } 464 464 // Return response 465 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));465 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 466 466 } 467 467 … … 497 497 } 498 498 // Return response 499 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));499 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 500 500 } 501 501 … … 553 553 } 554 554 // Return response 555 return array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'));556 } 555 return array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools')); 556 } -
ejabberd-account-tools/trunk/includes/captcha.php
r2501953 r3180156 229 229 break; 230 230 } 231 return $field;231 return isset($field) ? $field : ''; 232 232 } 233 233 -
ejabberd-account-tools/trunk/includes/change_email.php
r3175084 r3180156 103 103 } 104 104 // Create form 105 $html = $html ?: '<form data-action="change-email" class="ejabat" method="post" onsubmit="return false" autocomplete="off">106 '. $message.'105 $html = isset($html) ? $html : '<form data-action="change-email" class="ejabat" method="post" onsubmit="return false" autocomplete="off"> 106 '.(isset($message) ? $message : '').' 107 107 <p id="login" class="ejabat-validate"> 108 108 <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'"> … … 284 284 } 285 285 // Return response 286 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));287 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));288 } 286 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 287 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 288 } -
ejabberd-account-tools/trunk/includes/delete_account.php
r3174956 r3180156 85 85 <div id="response"></div> 86 86 </form>'; 87 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'nonce' => wp_create_nonce('wp_rest')));88 87 } 89 88 // Code expired or not valid … … 96 95 } 97 96 // Create form 98 $html = '<form data-action="delete-account" class="ejabat" method="post" onsubmit="return false" autocomplete="off">99 '. $message.'97 $html = isset($html) ? $html : '<form data-action="delete-account" class="ejabat" method="post" onsubmit="return false" autocomplete="off"> 98 '.(isset($message) ? $message : '').' 100 99 <p id="login" class="ejabat-validate"> 101 100 <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'"> … … 210 209 // Private email set 211 210 if(true == ($email = json_decode(strip_tags($response['body'])))) { 211 // Get current timestamp 212 $now = time(); 212 213 // Set code transient 213 214 $code = bin2hex(openssl_random_pseudo_bytes(16)); 214 $data = array('timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'user' => $user, 'host' => $host, 'email' => $email);215 $data = array('timestamp' => $now, 'ip' => $_SERVER['REMOTE_ADDR'], 'user' => $user, 'host' => $host, 'email' => $email); 215 216 set_transient('ejabat_unreg_'.$code, $data, get_option('ejabat_delete_account_timeout', 900)); 216 217 // Email data … … 252 253 } 253 254 // Return response 254 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));255 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));255 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 256 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 256 257 } 257 258 … … 323 324 // Delete account watcher 324 325 if(get_option('ejabat_watch_delete_account', false) && get_option('ejabat_watcher')) { 326 $now = time(); 325 327 $watchers = explode(' ', get_option('ejabat_watcher')); 326 328 foreach($watchers as $watcher) { … … 346 348 } 347 349 // Return response 348 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));349 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));350 } 350 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 351 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 352 } -
ejabberd-account-tools/trunk/includes/functions.php
r3176434 r3180156 38 38 list($user, $domain) = explode('@', $email); 39 39 // Check MX record 40 $arr= dns_get_record($domain, DNS_MX); 41 if($arr[0]['host'] == $domain && !empty($arr[0]['target'])) { 42 return true; 43 } 44 return false; 40 return checkdnsrr($domain, 'MX'); 45 41 } 46 42 … … 52 48 // Get disposable email status from cache 53 49 if(true == ($transient = get_transient('ejabat_usercheck_com_'.$domain))) { 54 return !$transient;50 return $transient; 55 51 } 56 52 else { … … 69 65 else if($response['response']['code'] == 200) { 70 66 // Save disposable email status to cache 71 set_transient('ejabat_usercheck_com_'.$domain, intval(json_decode($response['body'])->disposable));67 set_transient('ejabat_usercheck_com_'.$domain, !boolval(json_decode($response['body'])->disposable)); 72 68 // Return response body 73 return ! json_decode($response['body'])->disposable;69 return !boolval(json_decode($response['body'])->disposable); 74 70 } 75 71 } … … 110 106 } 111 107 // Return response 112 return rest_ensure_response(array('status' => $status ?: 'success'));108 return rest_ensure_response(array('status' => isset($status) ? $status : 'success')); 113 109 } 114 110 … … 195 191 } 196 192 // Return response 197 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools')));198 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));193 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'))); 194 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 199 195 } 200 196 … … 287 283 } 288 284 // Return response 289 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'session' => $session ?: 'expired'));290 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'session' => $session ?: 'expired', 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));285 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'session' => $session ?: 'expired')); 286 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'session' => $session ?: 'expired', 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 291 287 } 292 288 … … 323 319 } 324 320 // Return response 325 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools')));326 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));321 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'))); 322 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 327 323 } 328 324 … … 348 344 // Create nonce for logged in user 349 345 function ejabat_create_nonce() { 350 if(is_user_logged_in()) return wp_create_nonce('wp_rest'); 351 else return ''; 352 } 346 return is_user_logged_in() ? wp_create_nonce('wp_rest') : ''; 347 } -
ejabberd-account-tools/trunk/includes/register.php
r3175818 r3180156 102 102 if(true == ($transient = get_transient('ejabat_register_'.$request['code']))) { 103 103 // Verify required activation 104 if(json_decode(ejabat_get_xmpp_data('get_ban_details', array('user' => $transient['username'], 'host' => $transient['host']))['body'])->reason == 'Activation required') { 104 $response = ejabat_get_xmpp_data('get_ban_details', array('user' => $transient['username'], 'host' => $transient['host'])); 105 if((isset(json_decode($response['body'])->reason) ? json_decode($response['body'])->reason : '') == 'Activation required') { 105 106 // Try set correct password by unban account 106 107 $response = ejabat_get_xmpp_data('unban_account', array('user' => $transient['username'], 'host' => $transient['host'])); … … 166 167 $hosts = explode(' ', get_option('ejabat_registration_hosts', preg_replace('/^www\./','',$_SERVER['SERVER_NAME']))); 167 168 // Foreach hosts 169 $host_select = ''; 168 170 foreach($hosts as $host) { 169 171 $host_select .= '<option value="' . $host . '" ' . selected($request['host'], $host, false) . '>@' . $host . '</option>'; … … 175 177 </p>'; 176 178 // Create form 177 $html = $html ?: '<form data-action="register" class="ejabat" method="post" onsubmit="return false" autocomplete="off">178 '. $message.'179 $html = isset($html) ? $html : '<form data-action="register" class="ejabat" method="post" onsubmit="return false" autocomplete="off"> 180 '.(isset($message) ? $message : '').' 179 181 <p id="username" class="ejabat-validate ejabat-hint"> 180 182 <input type="text" name="username" placeholder="'.__('Username', 'ejabberd-account-tools').'"> … … 388 390 } 389 391 // Return response 390 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));391 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));392 } 392 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 393 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 394 } -
ejabberd-account-tools/trunk/includes/reset_password.php
r3176129 r3180156 97 97 <div id="response"></div> 98 98 </form>'; 99 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'nonce' => wp_create_nonce('wp_rest')));100 99 } 101 100 // Code expired or not valid … … 108 107 } 109 108 // Create form 110 $html = '<form data-action="reset-password" class="ejabat" method="post" onsubmit="return false" autocomplete="off">111 '. $message.'109 $html = isset($html) ? $html : '<form data-action="reset-password" class="ejabat" method="post" onsubmit="return false" autocomplete="off"> 110 '.(isset($message) ? $message : '').' 112 111 <p id="login" class="ejabat-validate"> 113 112 <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'"> … … 201 200 // Check if account is banned 202 201 $response = ejabat_get_xmpp_data('get_ban_details', array('user' => $user, 'host' => $host)); 203 if(!isset(json_decode($response['body'])->reason) || json_decode($response['body'])->reason== 'Activation required') {202 if(!isset(json_decode($response['body'])->reason) || (isset(json_decode($response['body'])->reason) ? json_decode($response['body'])->reason : '') == 'Activation required') { 204 203 // Get private email address 205 204 $response = ejabat_get_xmpp_data('private_get', array('user' => $user, 'host' => $host, 'element' => 'private', 'ns' => 'email')); … … 218 217 } 219 218 // Verification limit is not exceeded 220 if( $count< get_option('ejabat_reset_pass_limit_count', 4)) {219 if((isset($count) ? $count : 0) < get_option('ejabat_reset_pass_limit_count', 4)) { 221 220 // Get current timestamp 222 221 $now = time(); 223 222 // Set verification limit transient 224 $data = array('timestamp' => $now, 'ip' => $_SERVER['REMOTE_ADDR'], 'count' => $count+ 1);223 $data = array('timestamp' => $now, 'ip' => $_SERVER['REMOTE_ADDR'], 'count' => (isset($count) ? $count : 0) + 1); 225 224 set_transient('ejabat_pass_'.$user.'@'.$host, $data, get_option('ejabat_reset_pass_limit_timeout', 43200)); 226 225 // Set code transient … … 274 273 } 275 274 // Return response 276 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));277 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));275 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 276 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 278 277 } 279 278 … … 322 321 ejabat_get_xmpp_data('unban_ip', array('address' => $_SERVER['REMOTE_ADDR'])); 323 322 // Remove required activation 324 if(json_decode(ejabat_get_xmpp_data('get_ban_details', array('user' => $transient['user'], 'host' => $transient['host']))['body'])->reason == 'Activation required') { 323 $response = ejabat_get_xmpp_data('get_ban_details', array('user' => $transient['user'], 'host' => $transient['host'])); 324 if((isset(json_decode($response['body'])->reason) ? json_decode($response['body'])->reason : '') == 'Activation required') { 325 325 ejabat_get_xmpp_data('unban_account', array('user' => $transient['user'], 'host' => $transient['host'])); 326 326 } … … 362 362 } 363 363 // Return response 364 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields));365 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => $fields, 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));366 } 364 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null)); 365 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'fields' => isset($fields) ? $fields : null, 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 366 } -
ejabberd-account-tools/trunk/includes/webpresence.php
r3174956 r3180156 120 120 <div id="response"></div> 121 121 </form>'; 122 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'session' => $request['session'], 'nonce' => wp_create_nonce('wp_rest')));123 122 } 124 123 // Session expired or not valid … … 132 131 } 133 132 // Create login form 134 $html = '<form data-action="login" class="ejabat" method="post" onsubmit="return false" autocomplete="off">135 '. $message.'133 $html = isset($html) ? $html : '<form data-action="login" class="ejabat" method="post" onsubmit="return false" autocomplete="off"> 134 '.(isset($message) ? $message : '').' 136 135 <p id="login" class="ejabat-validate"> 137 136 <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'"> … … 272 271 } 273 272 // Return response 274 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools')));275 else return rest_ensure_response(array('status' => $status ?: 'error', 'message' => $message ?: __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => $response['body'], 'debug_code' => $response['code'], 'debug_command' => $response['command'], 'debug_arguments' => $response['arguments']));273 if(get_option('ejabat_debug', false) == false) return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'))); 274 else return rest_ensure_response(array('status' => isset($status) ? $status : 'error', 'message' => isset($message) ? $message : __('Unexpected error occurred, try again.', 'ejabberd-account-tools'), 'debug_message' => isset($response['body']) ? $response['body'] : null, 'debug_code' => isset($response['code']) ? $response['code'] : null, 'debug_command' => isset($response['command']) ? $response['command'] : null, 'debug_arguments' => isset($response['arguments']) ? $response['arguments'] : null)); 276 275 } 277 276
Note: See TracChangeset
for help on using the changeset viewer.