Plugin Directory

Changeset 3285730


Ignore:
Timestamp:
05/01/2025 03:44:28 PM (11 months ago)
Author:
listamester
Message:

security fix

Location:
listamester/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • listamester/trunk/includes/class-listamester-admin.php

    r2961364 r3285730  
    5050        <?php
    5151        if ( isset( $_POST['lm_user_id'] ) ) {
    52             /*
    53                 * OLD
    54             // check lmid, lmpwd
    55             $auth_basic = 'Basic ' . base64_encode( $_POST['lmid'] . ':' . $_POST['lmpwd'] );
    56             $args       = array(
    57                 'headers' => array( 'Authorization' => $auth_basic ),
    58             );
    59             */
    60             $args       = array(
    61                 'headers' => array( 'Authorization' =>"apikey ".$_POST['lm_user_id'].":".$_POST['lm_api_key']  ),
    62             );
    63             $resp       = wp_remote_get( self::LISTAMESTER_AUTH, $args );
    64                                     $success    = false;
    65             if ( ! empty( $resp['body'] ) ) {
    66                 $data = json_decode( $resp['body'], true );
    67                 if ( 'OK' === $data['status'] ) {
    68                     /*
    69                         * OLD
    70                     update_option( 'listamester_lmid', $_POST['lmid'] );
    71                     update_option( 'listamester_lmpwd', $data['pwdHash'] );
    72                     */
    73                                         update_option( 'lm_user_id', $_POST['lm_user_id'] );
    74                     update_option( 'lm_api_key', $_POST["lm_api_key"] );
    75                     $success = true;
     52            if ( ! isset( $_POST['lm_save_auth_params_nonce'] ) || ! wp_verify_nonce( $_POST['lm_save_auth_params_nonce'], 'lm_save_auth_params_action' ) ) {
     53                echo '<p style="font-weight: bold; color: red;">ACESS DENIED.</p>';
     54            } else {
     55                $args       = array(
     56                    'headers' => array( 'Authorization' =>"apikey ".$_POST['lm_user_id'].":".$_POST['lm_api_key']  ),
     57                );
     58                $resp       = wp_remote_get( self::LISTAMESTER_AUTH, $args );
     59                                        $success    = false;
     60                if ( ! empty( $resp['body'] ) ) {
     61                    $data = json_decode( $resp['body'], true );
     62                    if ( 'OK' === $data['status'] ) {
     63                        update_option( 'lm_user_id', $_POST['lm_user_id'] );
     64                        update_option( 'lm_api_key', $_POST["lm_api_key"] );
     65                        $success = true;
     66                    }
    7667                }
    77             }
    78             if ( $success ) {
    79                 echo '<br/><span style="font-weight: bold; color: green;">'
    80                     . esc_html__( 'Sikeres', 'listamester' ) . '</span>';
    81             } else {
    82                 echo '<br/><span style="font-weight: bold; color: red;">'
    83                     . esc_html__( 'Sikertelen azonosítás!', 'listamester' ) . '</span>';
     68                if ( $success ) {
     69                    echo '<p style="font-weight: bold; color: green;">'
     70                        . esc_html__( 'Sikeres mentés', 'listamester' ) . '</p>';
     71                } else {
     72                    echo '<p style="font-weight: bold; color: red;">'
     73                        . esc_html__( 'Sikertelen azonosítás!', 'listamester' ) . '</p>';
     74                }
    8475            }
    8576        }
     
    9990        </table>
    10091
     92        <?php wp_nonce_field('lm_save_auth_params_action', 'lm_save_auth_params_nonce'); ?>
    10193        <input type="submit" class="button button-primary" value="Mentés" />
    10294        </form>
     
    10698
    10799    function getAllForms() {
    108         /*
    109         $body = sprintf( '{"email":"%s","password":"%s"}', get_option( 'listamester_lmid' ), get_option( 'listamester_lmpwd' ) );
    110         $args = array(
    111             'headers' => array(
    112                 'Content-Type' => 'application/json',
    113             ),
    114             'body'    => $body,
    115         );
    116         $resp = wp_remote_post( self::LISTAMESTER_GET_ALL_FORMS, $args );
    117         */
    118100                    $args       = array(
    119101                'headers' => array( 'Authorization' =>"apikey ".get_option('lm_user_id').":".get_option('lm_api_key')  ),
     
    129111            }
    130112        }
    131         /*
    132         $resp = wp_remote_post( self::LISTAMESTER_GET_ALL_FORMS, $args );
    133         $forms = array();
    134         if ( ! empty( $resp['body'] ) ) {
    135             $forms = json_decode( $resp['body'], true );
    136                 if ( ! is_array( $forms ) ) {
    137                     $forms = array();
    138                 }
    139         }
    140         */
    141113        return $forms;
    142114    }
     
    157129            $forms = $this->getAllForms();
    158130            if ( ! empty( $forms ) ) {
    159                 foreach ( $forms as $form ) {
    160                     if ( empty( $form['id'] ) ) {
    161                         continue;
     131                if ( ! isset( $_POST['lm_flush_nonce'] ) || ! wp_verify_nonce( $_POST['lm_flush_nonce'], 'lm_flush_action' ) ) {
     132                    echo '<span style="font-weight: bold; color: red;">ACESS DENIED.</span><br /><br />';
     133                } else {
     134                    foreach ( $forms as $form ) {
     135                        if ( empty( $form['id'] ) ) {
     136                            continue;
     137                        }
     138                        delete_transient( 'listamester_form_' . $form['id'] );
     139                        delete_transient( 'listamester_html_' . $form['id'] );
     140                        delete_transient( 'listamester_js_' . $form['id'] );
    162141                    }
    163                     delete_transient( 'listamester_form_' . $form['id'] );
    164                     delete_transient( 'listamester_html_' . $form['id'] );
    165                     delete_transient( 'listamester_js_' . $form['id'] );
     142                    echo '<span style="font-weight: bold; color: green;">'
     143                        . esc_html__( 'Gyorsítótár kiürítve.', 'listamester' ) . '</span><br /><br />';
    166144                }
    167                 echo '<span style="font-weight: bold; color: green;">'
    168                     . esc_html__( 'Gyorsítótár kiürítve.', 'listamester' ) . '</span><br /><br />';
    169145            }
    170146        }
    171147        ?>
    172148        <form method="post">
     149            <?php wp_nonce_field('lm_flush_action', 'lm_flush_nonce'); ?>
    173150            <input type="submit" class="button button-primary" name="lmflush" value="Frissítés" />
    174151        </form>
  • listamester/trunk/listamester.php

    r3254966 r3285730  
    33 * Plugin Name: Listamester
    44 * Description: Hírlevélküldő, email marketing szolgáltatás WordPress-hez
    5  * Version: 2.3.6
     5 * Version: 2.3.7
    66 * Author: Listamester
    77 * Author URI: https://listamester.hu
  • listamester/trunk/readme.txt

    r3254966 r3285730  
    55Tested up to: 6.7.1
    66Requires PHP: 7.4.0
    7 Stable tag: 2.3.6
     7Stable tag: 2.3.7
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.