Current Path: > home > codekrsu > > escapematrixonline.com > wp-content > plugins > > optinmonster > OMAPI
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
EasyDigitalDownloads | Directory | - | - | |
Elementor | Directory | - | - | |
Integrations | Directory | - | - | |
MemberPress | Directory | - | - | |
Plugins | Directory | - | - | |
Promos | Directory | - | - | |
Rules | Directory | - | - | |
Shortcodes | Directory | - | - | |
WPForms | Directory | - | - | |
WooCommerce | Directory | - | - | |
Actions.php | File | 7126 bytes | February 25 2025 01:06:30. | |
Ajax.php | File | 1494 bytes | November 17 2021 04:02:26. | |
Api.php | File | 14508 bytes | February 25 2025 01:06:30. | |
ApiAuth.php | File | 2463 bytes | October 07 2021 23:34:50. | |
ApiKey.php | File | 5205 bytes | July 01 2024 22:14:00. | |
AssetLoader.php | File | 5721 bytes | April 01 2021 19:57:40. | |
BaseRestApi.php | File | 6807 bytes | October 15 2024 19:52:30. | |
Blocks.php | File | 13118 bytes | March 26 2025 18:07:30. | |
ClassicEditor.php | File | 7085 bytes | July 19 2022 01:42:26. | |
ConstantContact.php | File | 7602 bytes | July 01 2024 22:14:00. | |
Debug.php | File | 4453 bytes | July 01 2024 22:14:00. | |
EasyDigitalDownloads.php | File | 9553 bytes | July 01 2024 22:14:00. | |
Elementor.php | File | 5493 bytes | January 18 2023 22:34:56. | |
Inserter.php | File | 11562 bytes | September 14 2022 06:35:44. | |
InstallSkin.php | File | 1386 bytes | January 20 2021 22:11:00. | |
InstallSkinCompat.php | File | 1395 bytes | January 20 2021 22:11:00. | |
MailPoet.php | File | 13680 bytes | July 01 2024 22:14:00. | |
MemberPress.php | File | 4216 bytes | June 23 2023 01:24:22. | |
Menu.php | File | 15787 bytes | November 27 2024 23:45:46. | |
Notifications.php | File | 18910 bytes | October 15 2024 19:52:30. | |
OmuApi.php | File | 4122 bytes | October 27 2021 22:35:34. | |
Output.php | File | 24860 bytes | September 16 2024 23:28:26. | |
Pages.php | File | 17172 bytes | March 31 2025 18:30:04. | |
Partners.php | File | 4805 bytes | July 01 2024 22:14:00. | |
Plugins.php | File | 24923 bytes | April 23 2024 17:54:30. | |
Promos.php | File | 1132 bytes | September 14 2022 06:35:44. | |
Refresh.php | File | 5891 bytes | March 31 2025 18:30:04. | |
RestApi.php | File | 39506 bytes | October 15 2024 19:52:30. | |
RevenueAttribution.php | File | 3037 bytes | May 17 2022 18:55:22. | |
Review.php | File | 1482 bytes | September 08 2021 19:22:54. | |
Rules.php | File | 24003 bytes | July 01 2024 22:14:00. | |
Save.php | File | 11057 bytes | October 13 2023 01:19:08. | |
Shortcode.php | File | 3668 bytes | November 30 2021 23:04:18. | |
Sites.php | File | 8554 bytes | July 01 2024 22:14:00. | |
Support.php | File | 8446 bytes | February 25 2025 01:06:30. | |
Type.php | File | 2496 bytes | February 11 2023 00:30:54. | |
Urls.php | File | 8996 bytes | November 13 2024 02:13:58. | |
Utils.php | File | 7590 bytes | March 31 2025 18:30:04. | |
Validate.php | File | 9280 bytes | February 22 2024 23:03:38. | |
WPForms.php | File | 2666 bytes | July 27 2023 00:06:52. | |
Welcome.php | File | 4930 bytes | November 17 2021 04:02:26. | |
Widget.php | File | 6652 bytes | November 17 2021 04:02:26. | |
WooCommerce.php | File | 20046 bytes | July 01 2024 22:14:00. | |
Wordfence.php | File | 5606 bytes | October 09 2024 11:38:44. | |
WpErrorException.php | File | 714 bytes | November 17 2020 01:51:02. |
<?php /** * Api class. * * @since 1.0.0 * * @package OMAPI * @author Thomas Griffin */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Api class. * * @since 1.0.0 */ class OMAPI_Api { /** * Holds the last instantiated instance of this class. * * @var OMAPI_Api */ protected static $instance = null; /** * Base API route. * * @since 1.0.0 * * @var string */ public $base = OPTINMONSTER_API_URL; /** * Current API route. * * @since 1.0.0 * * @var bool|string */ public $route = false; /** * Full API URL endpoint. * * @since 1.0.0 * * @var bool|string */ public $url = false; /** * Current API method. * * @since 1.0.0 * * @var bool|string */ public $method = false; /** * API Username. * * @since 1.0.0 * * @var bool|string */ public $user = false; /** * API Key. * * @since 1.0.0 * * @var bool|string */ public $key = false; /** * New API Key. * * @since 1.3.4 * * @var bool|string */ public $apikey = false; /** * Plugin slug. * * @since 1.0.0 * * @var bool|string */ public $plugin = false; /** * The Api Version (v1 or v2) for this request. * * @since 1.8.0 * * @var string */ public $version = 'v1'; /** * Additional data to add to request body * * @since 1.0.0 * * @var array */ protected $additional_data = array(); /** * The HTTP response array. * * @since 1.6.5 * * @var null|array */ public $response = null; /** * The HTTP response code. * * @since 1.6.5 * * @var int */ public $response_code = 0; /** * The parsed HTTP response body. * * @since 1.6.5 * * @var mixed */ public $response_body = null; /** * JSON decode error from decoding the response, if found. * * @since 2.6.6 * * @var mixed */ public $decode_error = null; /** * Builds the API Object * * @since 1.8.0 * * @param string $version The Api Version (v1 or v2). * @param string $route The Api Endpoint/route. * @param string $method The Request method. * @param array $creds Array of API credentials. * * @return self */ public static function build( $version, $route, $method = 'POST', $creds = array() ) { if ( empty( $creds ) ) { $creds = OMAPI::get_instance()->get_api_credentials(); if ( ! empty( $creds ) ) { // Check if we have the new API and if so only use it. $creds = ! empty( $creds['apikey'] ) ? array( 'apikey' => $creds['apikey'] ) : array( 'user' => ! empty( $creds['user'] ) ? $creds['user'] : '', 'key' => ! empty( $creds['key'] ) ? $creds['key'] : '', ); } } return new self( $route, $creds, $method, $version ); } /** * Primary class constructor. * * @since 1.0.0 * * @param string $route The API route to target. * @param array $creds Array of API credentials. * @param string $method The API method. * @param string $version The version number of our API. */ public function __construct( $route, $creds, $method = 'POST', $version = 'v1' ) { // Set class properties. $this->route = $route; $this->version = $version; $this->method = $method; $this->user = ! empty( $creds['user'] ) ? $creds['user'] : ''; $this->key = ! empty( $creds['key'] ) ? $creds['key'] : ''; $this->apikey = ! empty( $creds['apikey'] ) ? $creds['apikey'] : ''; $this->plugin = OMAPI::get_instance()->plugin_slug; self::$instance = $this; } /** * Processes the API request. * * @since 1.0.0 * * @param array $args Request args. * * @return mixed $value The response to the API call. */ public function request( $args = array() ) { // Build the body of the request. $body = array( 'omapi-user' => $this->user, 'omapi-key' => $this->key, ); $body = array_filter( $body ); // If a plugin API request, add the data. if ( 'info' === $this->route || 'update' === $this->route ) { $body['omapi-plugin'] = $this->plugin; } // Add in additional data if needed. if ( ! empty( $this->additional_data ) ) { $body['omapi-data'] = maybe_serialize( $this->additional_data ); } $body = wp_parse_args( $args, $body ); $url = in_array( $this->method, array( 'GET', 'DELETE' ), true ) ? add_query_arg( array_map( 'urlencode', $body ), $this->get_url() ) : $this->get_url(); $url = esc_url_raw( $url ); $plugins = new OMAPI_Plugins(); // Build the headers of the request. $headers = array( 'Content-Type' => 'application/x-www-form-urlencoded', 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0', 'Pragma' => 'no-cache', 'Expires' => 0, 'Origin' => site_url(), 'OMAPI-Referer' => site_url(), 'OMAPI-Sender' => 'WordPress', 'OMAPI-Site' => esc_attr( get_option( 'blogname' ) ), 'OMAPI-Version' => esc_attr( OMAPI::get_instance()->version ), 'OMAPI-Plugins' => $plugins->get_active_plugins_header_value(), ); if ( $this->apikey ) { $headers['X-OptinMonster-ApiKey'] = $this->apikey; } // If the onboarding key is set, let's use that as the API key. if ( ! empty( $args['onboardingApiKey'] ) ) { $headers['X-OptinMonster-ApiKey'] = $args['onboardingApiKey']; } // Setup data to be sent to the API. $data = array( 'headers' => $headers, 'body' => $body, 'timeout' => 3000, 'sslverify' => false, 'method' => $this->method, ); // Perform the query and retrieve the response. $this->handle_response( wp_remote_request( $url, $data ) ); // Bail out early if there are any errors. if ( is_wp_error( $this->response ) ) { return $this->response; } // If we used the legacy api-creds, we'll get back a new api key. if ( empty( $this->apikey ) && ! empty( $this->response['headers']['x-optinmonster-apikey'] ) ) { $this->apikey = sanitize_text_field( $this->response['headers']['x-optinmonster-apikey'] ); } $error = $this->check_response_error(); // Bail out early if there are any errors. if ( is_wp_error( $error ) ) { return $error; } // Return the json decoded content. return $this->response_body; } /** * Handle setting up the object properties from the response. * * @since 2.6.6 * * @param object $response The response object from wp_remote_request. * * @return void */ public function handle_response( $response ) { $this->response = $response; // Get the response code and response body. $this->response_code = wp_remote_retrieve_response_code( $response ); $this->response_body = json_decode( wp_remote_retrieve_body( $response ) ); $this->decode_error = json_last_error(); } /** * Check for an error response, and return an applicable WP_Error instance. * * @since 2.6.6 * * @return boolean|WP_Error False if no errors, and WP_Error object if found. */ public function check_response_error() { $code = (int) $this->response_code; if ( $code < 400 ) { return false; } // If not successful status header, send back error. $type = ! empty( $this->response_body->type ) ? $this->response_body->type : 'api-error'; $message = ! empty( $this->response_body->message ) ? stripslashes( $this->response_body->message ) : ''; if ( empty( $message ) ) { $message = ! empty( $this->response_body->status_message ) ? stripslashes( $this->response_body->status_message ) : ''; } if ( empty( $message ) ) { $message = ! empty( $this->response_body->error ) ? stripslashes( $this->response_body->error ) : 'unknown'; } $message = sprintf( /* translators: %1$s - API response code, %2$s - returned error from API. */ __( 'The API returned a <strong>%1$s</strong> response with this message: <strong>%2$s</strong>', 'optin-monster-api' ), $this->response_code, $message ); return new WP_Error( $type, $message, $this->response_code ); } /** * The gets the URL based on our base, endpoint and version * * @since 1.8.0 * * @return string The API url. */ public function get_url() { return $this->base . '/' . $this->version . '/' . $this->route; } /** * Sets a class property. * * @since 1.0.0 * * @param string $key The property to set. * @param string $val The value to set for the property. * @return mixed $value The response to the API call. */ public function set( $key, $val ) { $this->{$key} = $val; } /** * Allow additional data to be passed in the request * * @since 1.0.0 * * @param array $data The data to set. * * @return void */ public function set_additional_data( array $data ) { $this->additional_data = array_merge( $this->additional_data, $data ); } /** * Clear additional data * * @since 1.9.0 * * return void */ public function clear_additional_data() { $this->additional_data = null; return $this; } /** * Get the request credentials for this API object. * * @since 2.3.0 * * @return array Array containing API credentials. */ public function get_creds() { return ! empty( $this->apikey ) ? array( 'apikey' => $this->apikey ) : array( 'user' => $this->user, 'key' => $this->key, ); } /** * Returns the last instantiated instance of this class. * * @since 1.9.10 * * @return OMAPI_Api A single instance of this class. */ public static function instance() { return self::$instance; } /** * Fetch from the OM /me route, and cache results if no error.. * * @since 2.6.6 * * @param bool $refresh Whether to refresh the cache. * @param array $creds Existing credentials array. * * @return array Requested /me data. */ public static function fetch_me_cached( $refresh = false, $creds = array() ) { $api = self::build( 'v2', 'me?includeOnboarding=true', 'GET', $creds ); $creds = array( $api->user, $api->key, $api->apikey ); $creds = array_filter( $creds ); $creds = array_values( $creds ); $cache_key = 'omapp_me_cached' . md5( implode( ':', $creds ) ); $result = get_transient( $cache_key ); if ( empty( $result ) || $refresh ) { $result = $api->request(); if ( ! is_wp_error( $result ) ) { set_transient( $cache_key, $result, DAY_IN_SECONDS ); // Force the option to be updated when we gather new data from the API. self::return_option_from_fetch( $result, array(), $creds, true ); } } return $result; } /** * Fetch from the OM /me route to complete the plugin connection after onboarding. * * This differs from `OMAPI_Api::fetch_me_cached` in that there is no results * caching. Fresh results are pulled every time this method is called. * * @since 2.16.6 * * @param array $creds Existing credentials array. * * @return array Requested /me data. */ public static function fetch_me_onboarding( $creds = array() ) { $api = self::build( 'v2', 'me?includeOnboarding=true', 'GET', $creds ); $result = $api->request( array( 'onboardingApiKey' => $creds['onboardingApiKey'] ) ); if ( ! is_wp_error( $result ) ) { // Force the option to be updated when we gather new data from the API. self::return_option_from_fetch( $result, array(), $creds, true ); OMAPI_ApiKey::init_connection( $api->apikey ); } return $result; } /** * Fetch from the OM /me route, and store data to our options. * * @since 2.0.0 * * @param array $option Existing options array. * @param array $creds Existing credentials array. * * @return array Updated options array. */ public static function fetch_me( $option = array(), $creds = array() ) { if ( ! empty( $creds['onboardingApiKey'] ) ) { $option = array(); $result = self::fetch_me_onboarding( $creds ); } else { $result = self::fetch_me_cached( true, $creds ); } if ( is_wp_error( $result ) ) { return $result; } return self::return_option_from_fetch( $result, $option, $creds, empty( $option ) ); } /** * Return the option after fetching data from the /me route, potentially * updating it in the database as well. * * @since 2.6.13 * * @param stdClass $result The /me route result. * @param array $option Possible option to be passed. * @param array $creds Possible creds to be passed. * @param bool $should_update Flag to update the option in the database or not. * * @return array Updated options array. */ public static function return_option_from_fetch( $result, $option = array(), $creds = array(), $should_update = false ) { $api = self::instance(); if ( $should_update ) { $option = OMAPI::get_instance()->get_option(); } // Make sure to set the new api key, if we have it. if ( empty( $option['api']['apikey'] ) && ! empty( $api->apikey ) ) { $option['api'] = array( 'apikey' => $api->apikey ); if ( $api->user && $api->key ) { // Notify user of credentials replacement. OMAPI::get_instance()->notifications->add_event( array( 'type' => 'success', 'title' => 'Your API Access Credentials have been updated', 'content' => 'We have automatically replaced your deprecated user/key OptinMonster connection credentials with a new API key.', 'btns' => array( 'main' => array( 'text' => 'Manage API Keys', 'url' => esc_url_raw( OPTINMONSTER_APP_URL . '/account/api/' ), ), ), ) ); } } if ( isset( $result->id ) ) { /* * The user id connecting the plugin. It could be the owner or any sub-account. * This key should not be used to embed codes or other API usage. * In those cases, the owner's id (accountUserId) would be the one to use. */ $option['userId'] = $result->id; } $to_store = array( 'accountId', 'accountUserId', 'currentLevel', 'plan', 'revenueAttribution' ); foreach ( $to_store as $key ) { if ( isset( $result->{$key} ) ) { $option[ $key ] = is_object( $result->{$key} ) ? (array) $result->{$key} : $result->{$key}; } } if ( $should_update ) { OMAPI::get_instance()->save->update_option( $option, $creds ); } return $option; } /** * Get the home/rest/admin url args. * * @since 2.13.0 * * @return array */ public static function get_url_args() { return array( 'homeUrl' => esc_url_raw( home_url() ), 'restUrl' => esc_url_raw( get_rest_url() ), 'adminUrl' => esc_url_raw( get_admin_url() ), ); } }
SILENT KILLER Tool