💥 TRENDING: Changeset/ - Collection

Changeset 3135233


Ignore:
Timestamp:
08/14/2024 03:37:17 AM (17 months ago)
Author:
njweller
Message:

New 1.16 version release

Location:
wpscan
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wpscan/tags/1.16/app/Notification.php

    r2529086 r3135233  
    1717    private $page;
    1818
     19    /** @var Plugin $parent */
     20    private $parent;
     21
    1922    /**
    2023     * Class constructor.
     
    4346        $total = $this->parent->get_total();
    4447
    45         register_setting( $this->page, $this->parent->OPT_EMAIL, array( $this, 'sanitize_email' ) );
    46         register_setting( $this->page, $this->parent->OPT_INTERVAL, array( $this, 'sanitize_interval' ) );
     48        \register_setting( $this->page, $this->parent->OPT_EMAIL, array( $this, 'sanitize_email' ) );
     49        \register_setting( $this->page, $this->parent->OPT_INTERVAL, array( $this, 'sanitize_interval' ) );
     50        \register_setting( $this->page, $this->parent->OPT_WEBHOOK, array( $this, 'sanitize_url' ) );
     51
    4752
    4853        $section = $this->page . '_section';
     
    6368        );
    6469
     70        $webhook_section = $this->page . '_webhook_section';
     71        add_settings_section( $webhook_section, null, array( $this, 'webhook_intro' ), $this->page );
    6572        add_settings_field(
    66             $this->parent->OPT_INTERVAL,
     73            $this->parent->OPT_WEBHOOK,
    6774            __( 'Send Alerts', 'wpscan' ),
    68             array( $this, 'field_interval' ),
     75            array( $this, 'field_webhook' ),
    6976            $this->page,
    70             $section
     77            $webhook_section
    7178        );
    7279    }
     
    117124     */
    118125    public function introduction() {
    119         echo '<p>' . __( 'Fill in the options below if you want to be notified by mail about new vulnerabilities. To add multiple e-mail addresses comma separate them.', 'wpscan' ) . '</p>';
     126        echo '<p>' . __( 'Enter one or more email addresses (separated by a comma) to be notified by email about new vulnerabilities.', 'wpscan' ) . '</p>';
    120127    }
    121128
     
    161168
    162169    /**
     170     * Instructions for the webhook setting field
     171     *
     172     * @since 1.0.0
     173     * @access public
     174     * @return string
     175     */
     176    public function webhook_intro() {
     177        echo '<p>' . __( 'Enter a webhook URL to receive report data as JSON.', 'wpscan' ) . '</p>';
     178    }
     179
     180    /**
     181     * Email field
     182     *
     183     * @since 1.0.0
     184     * @access public
     185     * @return string
     186     */
     187    public function field_webhook() {
     188        echo sprintf(
     189            '<input type="text" name="%s" value="%s" class="regular-text" placeholder="https://example.com/wpscan-webhook-receiver">',
     190            esc_attr( $this->parent->OPT_WEBHOOK ),
     191            esc_attr( get_option( $this->parent->OPT_WEBHOOK, '' ) )
     192        );
     193    }
     194
     195    /**
    163196     * Sanitize email
    164197     *
     
    201234
    202235    /**
     236     * Sanitize URL
     237     * @since 1.15.8
     238     * @access public
     239     *
     240     * @param string $value The URL to sanitize
     241     * @return string
     242     */
     243     public function sanitize_url( $value ) {
     244        if ( ! empty( $value ) ) {
     245            if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
     246                add_settings_error( $this->parent->OPT_WEBHOOK, 'invalid-url', __( 'You have entered an invalid webhook URL.', 'wpscan' ) );
     247                $value = '';
     248            }
     249        }
     250        return $value;
     251    }
     252
     253    /**
    203254     * Send the notification
    204255     *