Plugin Directory

Changeset 3180156


Ignore:
Timestamp:
11/01/2024 08:10:56 PM (16 months ago)
Author:
Beherit
Message:

Fixed several PHP warnings.

Location:
ejabberd-account-tools/trunk/includes
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ejabberd-account-tools/trunk/includes/admin-settings.php

    r3176434 r3180156  
    571571    $message = __('The cache has been successfully cleared.', 'ejabberd-account-tools');
    572572    // 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'));
    574574}
  • ejabberd-account-tools/trunk/includes/admin-tools.php

    r3176128 r3180156  
    7272                                            <th><?php _e('JID', 'ejabberd-account-tools'); ?></th>
    7373                                            <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']) : ''; ?>" />
    7575                                            </td>
    7676                                        </tr>
     
    7878                                            <th><?php _e('Email', 'ejabberd-account-tools'); ?></th>
    7979                                            <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']) : ''; ?>" />
    8181                                            </td>
    8282                                        </tr>
     
    101101                                            <th><?php _e('JID', 'ejabberd-account-tools'); ?></th>
    102102                                            <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']) : ''; ?>" />
    104104                                            </td>
    105105                                        </tr>
     
    107107                                            <th><?php _e('Reason', 'ejabberd-account-tools'); ?></th>
    108108                                            <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']) : ''; ?>" />
    110110                                            </td>
    111111                                        </tr>
     
    113113                                            <th><?php _e('Ban date', 'ejabberd-account-tools'); ?></th>
    114114                                            <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/>
    116116                                            </td>
    117117                                        </tr>
     
    137137                                            <th><?php _e('IP', 'ejabberd-account-tools'); ?></th>
    138138                                            <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']) : ''; ?>" />
    140140                                            </td>
    141141                                        </tr>
     
    158158                                            <th><?php _e('JID', 'ejabberd-account-tools'); ?></th>
    159159                                            <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']) : ''; ?>" />
    161161                                            </td>
    162162                                        </tr>
     
    164164                                            <th><?php _e('Subject', 'ejabberd-account-tools'); ?></th>
    165165                                            <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']) : ''; ?>" />
    167167                                            </td>
    168168                                        </tr>
     
    170170                                            <th><?php _e('Body', 'ejabberd-account-tools'); ?></th>
    171171                                            <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>
    173173                                            </td>
    174174                                        </tr>
     
    283283    }
    284284    // 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'));
    286286}
    287287
     
    335335    }
    336336    // 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'));
    338338}
    339339
     
    377377    }
    378378    // 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'));
    380380}
    381381
     
    419419    }
    420420    // 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'));
    422422}
    423423
     
    451451            // Ban details
    452452            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 : '';
    455455                $status = 'success';
    456456                $message = __('Ban details obtained successfully.', 'ejabberd-account-tools');
     
    463463    }
    464464    // 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'));
    466466}
    467467
     
    497497    }
    498498    // 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'));
    500500}
    501501
     
    553553    }
    554554    // 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  
    229229        break;
    230230    }
    231     return $field;
     231    return isset($field) ? $field : '';
    232232}
    233233
  • ejabberd-account-tools/trunk/includes/change_email.php

    r3175084 r3180156  
    103103        }
    104104        // 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 : '').'
    107107            <p id="login" class="ejabat-validate">
    108108                <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'">
     
    284284    }
    285285    // 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  
    8585                    <div id="response"></div>
    8686                </form>';
    87                 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'nonce' => wp_create_nonce('wp_rest')));
    8887            }
    8988            // Code expired or not valid
     
    9695        }
    9796        // 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 : '').'
    10099            <p id="login" class="ejabat-validate">
    101100                <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'">
     
    210209                            // Private email set
    211210                            if(true == ($email = json_decode(strip_tags($response['body'])))) {
     211                                // Get current timestamp
     212                                $now = time();
    212213                                // Set code transient
    213214                                $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);
    215216                                set_transient('ejabat_unreg_'.$code, $data, get_option('ejabat_delete_account_timeout', 900));
    216217                                // Email data
     
    252253    }
    253254    // 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));
    256257}
    257258
     
    323324                    // Delete account watcher
    324325                    if(get_option('ejabat_watch_delete_account', false) && get_option('ejabat_watcher')) {
     326                        $now = time();
    325327                        $watchers = explode(' ', get_option('ejabat_watcher'));
    326328                        foreach($watchers as $watcher) {
     
    346348    }
    347349    // 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  
    3838    list($user, $domain) = explode('@', $email);
    3939    // 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');
    4541}
    4642
     
    5248        // Get disposable email status from cache
    5349        if(true == ($transient = get_transient('ejabat_usercheck_com_'.$domain))) {
    54             return !$transient;
     50            return $transient;
    5551        }
    5652        else {
     
    6965            else if($response['response']['code'] == 200) {
    7066                // 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));
    7268                // Return response body
    73                 return !json_decode($response['body'])->disposable;
     69                return !boolval(json_decode($response['body'])->disposable);
    7470            }
    7571        }
     
    110106    }
    111107    // Return response
    112     return rest_ensure_response(array('status' => $status ?: 'success'));
     108    return rest_ensure_response(array('status' => isset($status) ? $status : 'success'));
    113109}
    114110
     
    195191    }
    196192    // 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));
    199195}
    200196
     
    287283    }
    288284    // 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));
    291287}
    292288
     
    323319    }
    324320    // 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));
    327323}
    328324
     
    348344// Create nonce for logged in user
    349345function 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  
    102102            if(true == ($transient = get_transient('ejabat_register_'.$request['code']))) {
    103103                // 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') {
    105106                    // Try set correct password by unban account
    106107                    $response = ejabat_get_xmpp_data('unban_account', array('user' => $transient['username'], 'host' => $transient['host']));
     
    166167        $hosts = explode(' ', get_option('ejabat_registration_hosts', preg_replace('/^www\./','',$_SERVER['SERVER_NAME'])));
    167168        // Foreach hosts
     169        $host_select = '';
    168170        foreach($hosts as $host) {
    169171            $host_select .= '<option value="' . $host . '" ' . selected($request['host'], $host, false) . '>@' . $host . '</option>';
     
    175177        </p>';
    176178        // 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 : '').'
    179181            <p id="username" class="ejabat-validate ejabat-hint">
    180182                <input type="text" name="username" placeholder="'.__('Username', 'ejabberd-account-tools').'">
     
    388390    }
    389391    // 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  
    9797                    <div id="response"></div>
    9898                </form>';
    99                 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'nonce' => wp_create_nonce('wp_rest')));
    10099            }
    101100            // Code expired or not valid
     
    108107        }
    109108        // 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 : '').'
    112111            <p id="login" class="ejabat-validate">
    113112                <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'">
     
    201200                        // Check if account is banned
    202201                        $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') {
    204203                            // Get private email address
    205204                            $response = ejabat_get_xmpp_data('private_get', array('user' => $user, 'host' => $host, 'element' => 'private', 'ns' => 'email'));
     
    218217                                    }
    219218                                    // 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)) {
    221220                                        // Get current timestamp
    222221                                        $now = time();
    223222                                        // 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);
    225224                                        set_transient('ejabat_pass_'.$user.'@'.$host, $data, get_option('ejabat_reset_pass_limit_timeout', 43200));
    226225                                        // Set code transient
     
    274273    }
    275274    // 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));
    278277}
    279278
     
    322321            ejabat_get_xmpp_data('unban_ip', array('address' => $_SERVER['REMOTE_ADDR']));
    323322            // 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') {
    325325                ejabat_get_xmpp_data('unban_account', array('user' => $transient['user'], 'host' => $transient['host']));
    326326            }
     
    362362    }
    363363    // 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  
    120120                    <div id="response"></div>
    121121                </form>';
    122                 return rest_ensure_response(array('data' => str_replace(array(PHP_EOL, "\t"), '', $html), 'session' => $request['session'], 'nonce' => wp_create_nonce('wp_rest')));
    123122            }
    124123            // Session expired or not valid
     
    132131        }
    133132        // 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 : '').'
    136135            <p id="login" class="ejabat-validate">
    137136                <input type="text" name="login" placeholder="'.__('Full username', 'ejabberd-account-tools').'">
     
    272271    }
    273272    // 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));
    276275}
    277276
Note: See TracChangeset for help on using the changeset viewer.