Plugin Directory

Changeset 3174956


Ignore:
Timestamp:
10/24/2024 12:00:04 PM (17 months ago)
Author:
Beherit
Message:

Required at least ejabberd 24.02.

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

Legend:

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

    r3031187 r3174956  
    223223                else if($response['code'] == 0) {
    224224                    // New email address different from current
    225                     if(empty($email) || ($email != strip_tags(json_decode($response['body'])->res))) {
     225                    if(empty($email) || ($email != json_decode(strip_tags($response['body'])))) {
    226226                        // Delete private email
    227227                        if(empty($email)) {
     
    303303            else if($response['code'] == 0) {
    304304                // Private email set
    305                 if(true == ($email = strip_tags(json_decode($response['body'])->res))) {
     305                if(true == ($email = json_decode(strip_tags($response['body'])))) {
    306306                    // Fetch email address
    307307                    $_POST['email'] = $email;
  • ejabberd-account-tools/trunk/includes/change_email.php

    r3031199 r3174956  
    238238                            else if($response['code'] == 0) {
    239239                                // New email address different from current
    240                                 if($request['email'] != strip_tags(json_decode($response['body'])->res)) {
     240                                if($request['email'] != json_decode(strip_tags($response['body']))) {
    241241                                    // Get current timestamp
    242242                                    $now = time();
     
    256256                                            $watchers = explode(' ', get_option('ejabat_watcher'));
    257257                                            foreach($watchers as $watcher) {
    258                                                 ejabat_get_xmpp_data('send_message', array('type' => 'chat', 'from' => $host, 'to' => $watcher, 'subject' => '', 'body' => sprintf('[%s] User %s has requested from IP address %s to change the email address from %s to %s', wp_date('Y-m-d H:i:s', $now), $user.'@'.$host, $_SERVER['REMOTE_ADDR'], strip_tags(json_decode($response['body'])->res), $request['email'])));
     258                                                ejabat_get_xmpp_data('send_message', array('type' => 'chat', 'from' => $host, 'to' => $watcher, 'subject' => '', 'body' => sprintf('[%s] User %s has requested from IP address %s to change the email address from %s to %s', wp_date('Y-m-d H:i:s', $now), $user.'@'.$host, $_SERVER['REMOTE_ADDR'], json_decode(strip_tags($response['body'])), $request['email'])));
    259259                                            }
    260260                                        }
  • ejabberd-account-tools/trunk/includes/delete_account.php

    r3031199 r3174956  
    209209                        else if($response['code'] == 0) {
    210210                            // Private email set
    211                             if(true == ($email = strip_tags(json_decode($response['body'])->res))) {
     211                            if(true == ($email = json_decode(strip_tags($response['body'])))) {
    212212                                // Set code transient
    213213                                $code = bin2hex(openssl_random_pseudo_bytes(16));
  • ejabberd-account-tools/trunk/includes/functions.php

    r3031187 r3174956  
    99
    1010// POST request to the XMPP server
    11 function ejabat_get_xmpp_data($command, $arguments = '') {
     11function ejabat_get_xmpp_data($command, $arguments = array()) {
    1212    // Perform request
    1313    $response = wp_remote_post(get_option('ejabat_rest_url').'/'.$command, array(
    1414        'headers' => array(
    1515            'Authorization' => 'Basic '.base64_encode(get_option('ejabat_login').':'.get_option('ejabat_password')),
    16             'X-Admin' => 'true'
     16            'Content-Type' => 'application/json'
    1717        ),
    18         'body' => json_encode($arguments),
     18        'body' => json_encode($arguments, JSON_FORCE_OBJECT),
    1919        'redirection' => 0,
    2020        'httpversion' => '1.1'
     
    2525    }
    2626    // Verify response
    27     else if(($response['response']['code'] == 200) || ($response['response']['code'] == 500)) {
    28         // Return response body
    29         if($response['response']['code'] == 200) {
    30             if(is_numeric($response['body'])) return array('code' => $response['body'], 'body' => $response['body'], 'command' => $command, 'arguments' => $arguments);
    31             else return array('code' => 0, 'body' => $response['body'], 'command' => $command, 'arguments' => $arguments);
    32         }
    33         else return array('code' => 1, 'body' => $response['body'], 'command' => $command, 'arguments' => $arguments);
     27    else if($response['response']['code'] == 200) {
     28        if(is_numeric($response['body'])) return array('code' => $response['body'], 'body' => $response['body'], 'command' => $command, 'arguments' => $arguments);
     29        else return array('code' => '0', 'body' => $response['body'], 'command' => $command, 'arguments' => $arguments);
    3430    }
    3531    // Unexpected error
     
    337333    // Nickname is set
    338334    if($response['code'] == 0) {
    339         return json_decode($response['body'])->content;
     335        return json_decode($response['body']);
    340336    }
    341337    else {
     
    344340        // Full name is set
    345341        if($response['code'] == 0) {
    346             return json_decode($response['body'])->content;
     342            return json_decode($response['body']);
    347343        }
    348344        else return $user;
  • ejabberd-account-tools/trunk/includes/reset_password.php

    r3031199 r3174956  
    209209                        else if($response['code'] == 0) {
    210210                            // Private email set
    211                             if(true == ($email = strip_tags(json_decode($response['body'])->res))) {
     211                            if(true == ($email = json_decode(strip_tags($response['body'])))) {
    212212                                // Check verification limit transient
    213213                                if(true == ($transient = get_transient('ejabat_pass_'.$user.'@'.$host))) {
  • ejabberd-account-tools/trunk/includes/webpresence.php

    r3031199 r3174956  
    7575                // Get Web Presence user settings
    7676                $response = ejabat_get_xmpp_data('private_get', array('user' => $transient['user'], 'host' => $transient['host'], 'element' => 'webpresence', 'ns' => 'css'));
    77                 $xml_css = @simplexml_load_string(json_decode($response['body'])->res)->webpresence;
     77                $xml_css = @simplexml_load_string(json_decode($response['body']))->webpresence;
    7878                $css = $xml_css->enabled ?: 'false';
    7979                $css_available = $xml_css->available ?: '#4caf50';
     
    8484                $css_unavailable = $xml_css->unavailable ?: '#9e9e9e';
    8585                $response = ejabat_get_xmpp_data('private_get', array('user' => $transient['user'], 'host' => $transient['host'], 'element' => 'webpresence', 'ns' => 'json'));
    86                 $json = @simplexml_load_string(json_decode($response['body'])->res)->webpresence->enabled ?: 'false';
     86                $json = @simplexml_load_string(json_decode($response['body']))->webpresence->enabled ?: 'false';
    8787                // Create configuration form
    8888                $html = '<form data-action="configure-webpresence" class="ejabat" method="post" onsubmit="return false" autocomplete="off">
     
    296296        // Get webpresence settins from XMPP server
    297297        $response = ejabat_get_xmpp_data('private_get', array('user' => $user, 'host' => $host, 'element' => 'webpresence', 'ns' => 'css'));
    298         $xml = (array)@simplexml_load_string(json_decode($response['body'])->res)->webpresence;
     298        $xml = (array)@simplexml_load_string(json_decode($response['body']))->webpresence;
    299299        // Save settings to cache
    300300        $transient = array(
     
    372372        // Get webpresence settins from XMPP server
    373373        $response = ejabat_get_xmpp_data('private_get', array('user' => $user, 'host' => $host, 'element' => 'webpresence', 'ns' => 'json'));
    374         $xml = (array)@simplexml_load_string(json_decode($response['body'])->res)->webpresence;
     374        $xml = (array)@simplexml_load_string(json_decode($response['body']))->webpresence;
    375375        // Save settings to cache
    376376        $transient = $xml['enabled'] ?: 'false';
Note: See TracChangeset for help on using the changeset viewer.