Plugin Directory

Changeset 3176431


Ignore:
Timestamp:
10/27/2024 05:33:54 PM (17 months ago)
Author:
Beherit
Message:

Basic support for OAuth tokens

Location:
xmpp-statistics/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • xmpp-statistics/trunk/includes/functions.php

    r3174505 r3176431  
    1313    $response = wp_remote_post(get_option('xmpp_stats_rest_url').'/'.$command, array(
    1414        'headers' => array(
    15             'Authorization' => 'Basic '.base64_encode(get_option('xmpp_stats_login').':'.get_option('xmpp_stats_password')),
    16             'Content-Type' => 'application/json' 
     15            'Authorization' => empty(get_option('xmpp_stats_oauth_token')) ? 'Basic '.base64_encode(get_option('xmpp_stats_login').':'.get_option('xmpp_stats_password')) : 'Bearer '.get_option('xmpp_stats_oauth_token'),
     16            'Content-Type' => 'application/json'
    1717        ),
    1818        'body' => json_encode($arguments, JSON_FORCE_OBJECT),
  • xmpp-statistics/trunk/includes/settings.php

    r3102789 r3176431  
    1111function xmpp_stats_register_settings() {
    1212    register_setting('xmpp_stats_settings', 'xmpp_stats_rest_url', array('type' => 'string', 'sanitize_callback' => 'trim'));
     13    register_setting('xmpp_stats_settings', 'xmpp_stats_login', array('type' => 'string', 'sanitize_email' => 'trim'));
     14    register_setting('xmpp_stats_settings', 'xmpp_stats_password', array('type' => 'string', 'sanitize_callback' => 'trim'));
     15    register_setting('xmpp_stats_settings', 'xmpp_stats_oauth_token', array('type' => 'string', 'sanitize_callback' => 'trim'));
    1316    register_setting('xmpp_stats_settings', 'xmpp_stats_save_data', array('type' => 'boolean', 'sanitize_callback' => 'boolval'));
    1417    register_setting('xmpp_stats_settings', 'xmpp_stats_delete_old_data', array('type' => 'boolean', 'sanitize_callback' => 'boolval'));
    15     register_setting('xmpp_stats_settings', 'xmpp_stats_login', array('type' => 'string', 'sanitize_email' => 'trim'));
    16     register_setting('xmpp_stats_settings', 'xmpp_stats_password', array('type' => 'string', 'sanitize_callback' => 'trim'));
    1718    register_setting('xmpp_stats_settings', 'xmpp_stats_chart_width', array('type' => 'integer', 'sanitize_callback' => 'intval'));
    1819    register_setting('xmpp_stats_settings', 'xmpp_stats_chart_height', array('type' => 'integer', 'sanitize_callback' => 'intval'));
     
    131132                <div id="postbox-container-2" class="postbox-container">
    132133                    <div id="normal-sortables" class="meta-box-sortables">
    133                         <div class="postbox">
    134                             <h2 class="hndle"><?php _e('Settings', 'xmpp-statistics'); ?></h2>
    135                             <form id="xmpp-stats-form" method="post" action="options.php">
    136                                 <?php settings_fields('xmpp_stats_settings'); ?>
     134                        <form id="xmpp-stats-form" method="post" action="options.php">
     135                            <?php settings_fields('xmpp_stats_settings'); ?>
     136                            <div class="postbox">
     137                                <div class="postbox-header">
     138                                    <h2 class="hndle"><?php _e('ReST API', 'xmpp-statistics'); ?></h2>
     139                                </div>
    137140                                <div class="inside">
    138141                                    <table class="form-table"><tbody>
     
    153156                                            <th><?php _e('Password', 'xmpp-statistics'); ?></th>
    154157                                            <td>
    155                                                 <input name="xmpp_stats_password" id="xmpp_stats_password" type="password" size="40" value="<?php echo get_option('xmpp_stats_password'); ?>" />
    156                                             </td>
    157                                         </tr>
     158                                                <input name="xmpp_stats_password" id="xmpp_stats_password" type="password" size="40" autocomplete="new-password" value="<?php echo get_option('xmpp_stats_password'); ?>" />
     159                                            </td>
     160                                        </tr>
     161                                        <tr>
     162                                            <th><?php _e('OAuth token', 'xmpp-statistics'); ?></th>
     163                                            <td>
     164                                                <input name="xmpp_stats_oauth_token" id="xmpp_stats_oauth_token" type="text" size="40" value="<?php echo get_option('xmpp_stats_oauth_token'); ?>" />
     165                                                <p class="description"><?php printf(__('Use instead of classic login and password access. The plugin doesn\'t generate and check the expiration date of OAuth tokens, so you need to generate OAuth token for your own with long expiration date. To generate a token use the oauth_issue_token command with the ejabberdctl shell script e.g.: %s', 'xmpp-statistics'), '<kbd>ejabberdctl oauth_issue_token bot@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']).' 315360000 ejabberd:admin</kbd>'); ?></p>
     166                                            </td>
     167                                        </tr>
     168                                    </tbody></table>   
     169                                </div>
     170                            </div> 
     171                            <div class="postbox">
     172                                <div class="postbox-header">
     173                                    <h2 class="hndle"><?php _e('Charts with statistics', 'xmpp-statistics'); ?></h2>
     174                                </div>
     175                                <div class="inside">
     176                                    <table class="form-table"><tbody>           
    158177                                        <tr>
    159178                                            <th><?php _e('Statistics', 'xmpp-statistics'); ?></th>
    160179                                            <td>
    161180                                                <label for="xmpp_stats_save_data"><input name="xmpp_stats_save_data" id="xmpp_stats_save_data" type="checkbox" value="1" <?php checked(1, get_option('xmpp_stats_save_data', false)); ?> /><?php _e('Save statistics', 'xmpp-statistics'); ?></label>
    162                                                 <p class="description"><?php printf(__('Automatically retrieves server statistics every 5 minutes and stores them in a database. WP Cron fires only on the page visit, so plugin may work incorrectly - to prevent such situations, you must disable WP Cron by adding %s to wp-config.php and adding a task to the system cron, for example: %s.', 'xmpp-statistics'), '<kbd style="font-size:smaller;">define(\'DISABLE_WP_CRON\', true);</kbd>', '<kbd style="font-size:smaller;">*/1 * * * * /usr/bin/php '.get_home_path().'wp-cron.php</kbd>'); ?></p>
     181                                                <p class="description"><?php printf(__('Automatically retrieves server statistics every 5 minutes and stores them in a database. WP Cron fires only on the page visit, so plugin may work incorrectly - to prevent such situations, you must disable WP Cron by adding %s to wp-config.php and adding a task to the system cron, for example: %s.', 'xmpp-statistics'), '<kbd>define(\'DISABLE_WP_CRON\', true);</kbd>', '<kbd>*/1 * * * * /usr/bin/php '.get_home_path().'wp-cron.php</kbd>'); ?></p>
    163182                                            </td>
    164183                                        </tr>
     
    206225                                        </tr>
    207226                                    </tbody></table>
    208                                 </div>
    209                                 <div id="major-publishing-actions">
    210                                     <div id="publishing-action">
    211                                         <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save settings', 'xmpp-statistics'); ?>" />
    212                                     </div>
    213                                     <div class="clear"></div>
    214                                 </div>
    215                             </form>
    216                         </div>
     227                                </div>                     
     228                            </div>
     229                            <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save settings', 'xmpp-statistics'); ?>" />
     230                        </form>
    217231                    </div>
    218232                </div>
  • xmpp-statistics/trunk/uninstall.php

    r3052196 r3176431  
    1111// Remove settings options
    1212delete_option('xmpp_stats_rest_url');
     13delete_option('xmpp_stats_login');
     14delete_option('xmpp_stats_password');
     15delete_option('xmpp_stats_oauth_token');
    1316delete_option('xmpp_stats_save_data');
    1417delete_option('xmpp_stats_delete_old_data');
    15 delete_option('xmpp_stats_login');
    16 delete_option('xmpp_stats_password');
    1718delete_option('xmpp_stats_chart_line_color');
    1819delete_option('xmpp_stats_chart_line_color2');
  • xmpp-statistics/trunk/xmpp-statistics.pot

    r3102789 r3176431  
    33msgstr ""
    44"Project-Id-Version: XMPP Statistics\n"
    5 "POT-Creation-Date: 2024-06-14 15:22+0200\n"
     5"POT-Creation-Date: 2024-10-27 18:29+0100\n"
    66"PO-Revision-Date: 2019-09-12 15:34+0200\n"
    77"Last-Translator: \n"
     
    1212"Content-Transfer-Encoding: 8bit\n"
    1313"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    14 "X-Generator: Poedit 3.4.4\n"
     14"X-Generator: Poedit 3.5\n"
    1515"X-Poedit-Basepath: .\n"
    1616"X-Poedit-SourceCharset: UTF-8\n"
     
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: includes/charts.php:52 includes/charts.php:181 includes/settings.php:351
    21 #: includes/settings.php:352
     20#: includes/charts.php:52 includes/charts.php:181 includes/settings.php:365
     21#: includes/settings.php:366
    2222msgid "Logged in users"
    2323msgstr ""
     
    2525#: includes/charts.php:52 includes/charts.php:297 includes/charts.php:494
    2626#: includes/charts.php:689 includes/charts.php:884 includes/charts.php:1135
    27 #: includes/charts.php:1386 includes/charts.php:1637 includes/settings.php:351
    28 #: includes/settings.php:353 includes/settings.php:355
    29 #: includes/settings.php:357 includes/settings.php:359
    30 #: includes/settings.php:361 includes/settings.php:363
     27#: includes/charts.php:1386 includes/charts.php:1637 includes/settings.php:365
     28#: includes/settings.php:367 includes/settings.php:369
     29#: includes/settings.php:371 includes/settings.php:373
     30#: includes/settings.php:375 includes/settings.php:377
    3131msgid "by day"
    3232msgstr ""
     
    5858#: includes/charts.php:181 includes/charts.php:396 includes/charts.php:591
    5959#: includes/charts.php:786 includes/charts.php:1013 includes/charts.php:1264
    60 #: includes/charts.php:1515 includes/charts.php:1766 includes/settings.php:352
    61 #: includes/settings.php:354 includes/settings.php:356
    62 #: includes/settings.php:358 includes/settings.php:360
    63 #: includes/settings.php:362 includes/settings.php:364
     60#: includes/charts.php:1515 includes/charts.php:1766 includes/settings.php:366
     61#: includes/settings.php:368 includes/settings.php:370
     62#: includes/settings.php:372 includes/settings.php:374
     63#: includes/settings.php:376 includes/settings.php:378
    6464msgid "by week"
    6565msgstr ""
    6666
    67 #: includes/charts.php:297 includes/charts.php:396 includes/settings.php:353
    68 #: includes/settings.php:354
     67#: includes/charts.php:297 includes/charts.php:396 includes/settings.php:367
     68#: includes/settings.php:368
    6969msgid "Registered users"
    7070msgstr ""
    7171
    72 #: includes/charts.php:494 includes/charts.php:591 includes/settings.php:334
    73 #: includes/settings.php:355 includes/settings.php:356
     72#: includes/charts.php:494 includes/charts.php:591 includes/settings.php:348
     73#: includes/settings.php:369 includes/settings.php:370
    7474msgid "XMPP server uptime"
    7575msgstr ""
    7676
    77 #: includes/charts.php:689 includes/charts.php:786 includes/settings.php:336
    78 #: includes/settings.php:357 includes/settings.php:358
     77#: includes/charts.php:689 includes/charts.php:786 includes/settings.php:350
     78#: includes/settings.php:371 includes/settings.php:372
    7979msgid "System uptime"
    8080msgstr ""
    8181
    82 #: includes/charts.php:884 includes/charts.php:1013 includes/settings.php:337
    83 #: includes/settings.php:359 includes/settings.php:360
     82#: includes/charts.php:884 includes/charts.php:1013 includes/settings.php:351
     83#: includes/settings.php:373 includes/settings.php:374
    8484msgid "RAM memory usage"
    8585msgstr ""
     
    9595msgstr ""
    9696
    97 #: includes/charts.php:1386 includes/charts.php:1515 includes/settings.php:361
    98 #: includes/settings.php:362
     97#: includes/charts.php:1386 includes/charts.php:1515 includes/settings.php:375
     98#: includes/settings.php:376
    9999msgid "Outgoing S2S connections"
    100100msgstr ""
     
    105105msgstr ""
    106106
    107 #: includes/charts.php:1637 includes/charts.php:1766 includes/settings.php:363
    108 #: includes/settings.php:364
     107#: includes/charts.php:1637 includes/charts.php:1766 includes/settings.php:377
     108#: includes/settings.php:378
    109109msgid "Incoming S2S connections"
    110110msgstr ""
     
    118118msgstr ""
    119119
    120 #: includes/settings.php:28 includes/settings.php:134
     120#: includes/settings.php:29
    121121msgid "Settings"
    122122msgstr ""
    123123
    124 #: includes/settings.php:128
     124#: includes/settings.php:129
    125125msgid "XMPP server statistics"
    126126msgstr ""
    127127
    128 #: includes/settings.php:140
     128#: includes/settings.php:138
     129msgid "ReST API"
     130msgstr ""
     131
     132#: includes/settings.php:143
    129133msgid "API address"
    130134msgstr ""
    131135
    132 #: includes/settings.php:143
     136#: includes/settings.php:146
    133137msgid "Enter URL address defined for module mod_http_api in ejabberd settings."
    134138msgstr ""
    135139
    136 #: includes/settings.php:147
     140#: includes/settings.php:150
    137141msgid "Login"
    138142msgstr ""
    139143
    140 #: includes/settings.php:153
     144#: includes/settings.php:156
    141145msgid "Password"
    142146msgstr ""
    143147
    144 #: includes/settings.php:159
     148#: includes/settings.php:162
     149msgid "OAuth token"
     150msgstr ""
     151
     152#: includes/settings.php:165
     153#, php-format
     154msgid ""
     155"Use instead of classic login and password access. The plugin doesn't "
     156"generate and check the expiration date of OAuth tokens, so you need to "
     157"generate OAuth token for your own with long expiration date. To generate a "
     158"token use the oauth_issue_token command with the ejabberdctl shell script e."
     159"g.: %s"
     160msgstr ""
     161
     162#: includes/settings.php:173
     163msgid "Charts with statistics"
     164msgstr ""
     165
     166#: includes/settings.php:178
    145167msgid "Statistics"
    146168msgstr ""
    147169
    148 #: includes/settings.php:161
     170#: includes/settings.php:180
    149171msgid "Save statistics"
    150172msgstr ""
    151173
    152 #: includes/settings.php:162
     174#: includes/settings.php:181
    153175#, php-format
    154176msgid ""
     
    159181msgstr ""
    160182
    161 #: includes/settings.php:166
     183#: includes/settings.php:185
    162184msgid "Cleaning"
    163185msgstr ""
    164186
    165 #: includes/settings.php:168
     187#: includes/settings.php:187
    166188msgid "Automatically delete unnecessary data from the database"
    167189msgstr ""
    168190
    169 #: includes/settings.php:169
     191#: includes/settings.php:188
    170192msgid ""
    171193"Use this option with caution - it irrevocably removes data older than 2 "
     
    173195msgstr ""
    174196
    175 #: includes/settings.php:173
     197#: includes/settings.php:192
    176198msgid "Charts width"
    177199msgstr ""
    178200
    179 #: includes/settings.php:179
     201#: includes/settings.php:198
    180202msgid "Charts height"
    181203msgstr ""
    182204
    183 #: includes/settings.php:185
     205#: includes/settings.php:204
    184206msgid "Charts lines color"
    185207msgstr ""
    186208
    187 #: includes/settings.php:194
     209#: includes/settings.php:213
    188210msgid "Charts grid color"
    189211msgstr ""
    190212
    191 #: includes/settings.php:200
     213#: includes/settings.php:219
    192214msgid "Previous data in charts"
    193215msgstr ""
    194216
    195 #: includes/settings.php:203
     217#: includes/settings.php:222
    196218msgid "from yesterday"
    197219msgstr ""
    198220
    199 #: includes/settings.php:203
     221#: includes/settings.php:222
    200222msgid "from last week"
    201223msgstr ""
    202224
    203 #: includes/settings.php:204
     225#: includes/settings.php:223
    204226msgid "Specifies the data range for daily charts."
    205227msgstr ""
    206228
    207 #: includes/settings.php:211
     229#: includes/settings.php:229
    208230msgid "Save settings"
    209231msgstr ""
    210232
    211 #: includes/settings.php:223
     233#: includes/settings.php:237
    212234msgid "If you like this plugin please give a review at WordPress.org."
    213235msgstr ""
    214236
    215 #: includes/settings.php:229
     237#: includes/settings.php:243
    216238msgid "Usage information"
    217239msgstr ""
    218240
    219 #: includes/settings.php:235
     241#: includes/settings.php:249
    220242#, php-format
    221243msgid ""
     
    224246msgstr ""
    225247
    226 #: includes/settings.php:236
     248#: includes/settings.php:250
    227249#, php-format
    228250msgid ""
     
    231253msgstr ""
    232254
    233 #: includes/settings.php:255
     255#: includes/settings.php:269
    234256msgid ""
    235257"Then configure ReST API url and authorization data, finally put shortcodes "
     
    237259msgstr ""
    238260
    239 #: includes/settings.php:256
     261#: includes/settings.php:270
    240262msgid ""
    241263"For information about the system, use e.g. Nginx and Lua module. Plugin will "
     
    244266msgstr ""
    245267
    246 #: includes/settings.php:323
     268#: includes/settings.php:337
    247269msgid "Simple shortcodes"
    248270msgstr ""
    249271
    250 #: includes/settings.php:330
     272#: includes/settings.php:344
    251273msgid "Online users count"
    252274msgstr ""
    253275
    254 #: includes/settings.php:330 includes/settings.php:331
    255 #: includes/settings.php:332 includes/settings.php:333
    256 #: includes/settings.php:334 includes/settings.php:335
     276#: includes/settings.php:344 includes/settings.php:345
     277#: includes/settings.php:346 includes/settings.php:347
     278#: includes/settings.php:348 includes/settings.php:349
    257279msgid "Command"
    258280msgstr ""
    259281
    260 #: includes/settings.php:331
     282#: includes/settings.php:345
    261283msgid "Registered users count"
    262284msgstr ""
    263285
    264 #: includes/settings.php:332
     286#: includes/settings.php:346
    265287msgid "Outgoing s2s connections count"
    266288msgstr ""
    267289
    268 #: includes/settings.php:333
     290#: includes/settings.php:347
    269291msgid "Incoming s2s connections count"
    270292msgstr ""
    271293
    272 #: includes/settings.php:335
     294#: includes/settings.php:349
    273295msgid "XMPP server version"
    274296msgstr ""
    275297
    276 #: includes/settings.php:338
     298#: includes/settings.php:352
    277299msgid "System version"
    278300msgstr ""
    279301
    280 #: includes/settings.php:344
     302#: includes/settings.php:358
    281303msgid "Shortcodes for charts"
    282304msgstr ""
Note: See TracChangeset for help on using the changeset viewer.