// 'that' => // ... // 'the_other_thing' => // ) // // RETURNS // On SUCCESS // o TRUE // If there was NO passback data (or in other words, // the Central site replied "--OK--"). // o ARRAY $api_passback_data // If the Central site replied "--OK-WITH-DATA--" // (though the array may be empty) // // On FAILURE // $error_message STRING // This string might be either:- // o A error message or other (eg; debugging) string, // passed back from the Central site, or; // o An error message string generated by this routine // (or one of it's sub-routines). // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // NOTES! // ------ // 1. Here we should have (eg):- // // $_GET = Array( // [page] => pluginPlant // [action] => custom-page // [application] => selective-exporter // [custom_page] => export-pages // ) // // 2. At this point, the following GET variables:- // o 'page' // o 'action' // o 'application' // o 'custom_page' // // have been validated - and are OK. // // 3. All, other (eg; custom page specific,) GET variables are unchecked. // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $_GET , '$_GET' ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $_POST = Array() // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $_POST , '$_POST' ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $_COOKIE , '$_COOKIE' ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $loaded_datasets = Array( // // [ad_swapper_ads_outgoing] => Array( // [title] => Ads - Outgoing // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1417157309 // [last_modified_server_datetime_utc] => 1417157309 // [key] => 9d9836e7-e8fd-4ca0-a848-ceef839e04ad-1417157309-463474-1176 // [site_key] => // [image_url] => http://localhost/plugdev/wp-content/uploads/2014/06/rookie-mag-postcards-from-wonderland.jpeg // [link_url] => http://www.google.co.nz // [alt_text] => // [description] => // [start_datetime] => // [end_datetime] => // [question_disabled] => // [aspect_ratio_min] => // [aspect_ratio_max] => // [sequence_number] => // ) // ) // [key_field_slug] => key // [record_indices_by_key] => Array( // [9d9836e7-e8fd-4ca0-a848-ceef839e04ad-1417157309-463474-1176] => 0 // ) // // ) // // [ad_swapper_impressions] => Array( // [title] => Impressions // [records] => Array() // [key_field_slug] => key // [record_indices_by_key] => Array() // ) // // [ad_swapper_plugin_settings] => Array( // [title] => Plugin Settings // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1417930162 // [last_modified_server_datetime_utc] => 1417930162 // [key] => abd1d6f4-7865-487b-a668-0fcbab0f17d3-1417930162-821262-1282 // [ad_swapper_user_sid] => gcmv-2mpy-xkwc-39kg-m9c3-939h // [plugin_registration_key] => MoHnDSq88CX.../fU1RA7IR // [api_public_encryption_key] => xxx // [ad_swapper_site_sid] => 7cnc-npvh-cd3m-vyk4-czdd-72dh // [api_url_override] => // ) // ) // [key_field_slug] => key // [record_indices_by_key] => Array( // [abd1d6f4-7865-487b-a668-0fcbab0f17d3-1417930162-821262-1282] => 0 // ) // ) // // [ad_swapper_site_profile] => Array( // [title] => Site Profile // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1417839045 // [last_modified_server_datetime_utc] => 1417839045 // [key] => 68fb3737-d4a7-481f-a941-b82e916b0b6c-1417839045-460169-1281 // [site_title] => Plugdev // [home_page_url] => http://localhost/plugdev // [general_description] => // [ads_wanted_description] => // [sites_wanted_description] => // [categories_available] => // [categories_wanted] => // ) // ) // [key_field_slug] => key // [record_indices_by_key] => Array( // [68fb3737-d4a7-481f-a941-b82e916b0b6c-1417839045-460169-1281] => 0 // ) // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $loaded_datasets ) ; // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // Get/check the PLUGIN SETTINGS record... // ========================================================================= $dataset_slug = 'ad_swapper_plugin_settings' ; // ------------------------------------------------------------------------- if ( count( $loaded_datasets[ $dataset_slug ]['records'] ) < 1 ) { // --------------------------------------------------------------------- // Site Not Registered !!! // --------------------------------------------------------------------- $msg = get_site_not_registered_message( $core_plugapp_dirs , $question_front_end , $dataset_slug ) ; // --------------------------------------------------------------------- $msg = <<{$msg} EOT; // --------------------------------------------------------------------- return $msg ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $plugin_settings_record = $loaded_datasets[ $dataset_slug ]['records']['0'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $plugin_settings_record = Array( // [created_server_datetime_utc] => 1418504111 // [last_modified_server_datetime_utc] => 1418504111 // [key] => e951e234-1a3c-4e36-9af5-4be029b6ad00-1418504111-379967-1359 // [ad_swapper_user_sid] => nddn-kmzv // [ad_swapper_site_sid] => ndd4-gvzw // [site_registration_key] => 13bff54471fa2c61777daaa9e68537f1def19058ad96ab0130fb92ddbcfc24f50e2d0ab0a1ece32209e3485640d3d510ed99b968937ec1276d4d95886ba8a5d197c5971db521a6e47f75523bb10f324f660195d8f3214944f088df277923012e56c1683acd7afca81128a629788e08e62a3fc3c14a1ec9e4d8757f94ee178e341692cc77f2dcd9bade8cd2646cbe08abddbfbd0f0ce3b1edca23672890f11ec3c48b57a2356d63625a7b0cd0cf2ec245233ec57211b0df39c1ad37b618bbb57d34d7d8564a0090cb928ce10fc5fd28413eea98a25df8d8c11db9a3961c1ec43372be699440047aebefd8cf1d8bb94d8e35b8b273a812054f9fbf6e18b4d7168e346462abc21fc56e85c5492693667cf7e1fc97b9ae5b4d0840e002d35dee6a8c09750349fc1fb4808abcf593b89a85275189dec047c51d8fa5656d10855578b94fa6d3648d7a3615c8a9467e3cc9bc80ba9a28c8eeb3166b0671f2d52219d05b7d9cdb6a6e58deb039fa054be196b5ba459c211f8c55bab445fcd8233761272acc07285a866a43f5febad090c4f88b7f5355ad46b79d208568d23dc458414cd174c0c1e19ecc32fbbf5a833b257f80735b4e94dfb5adc7ddd4fd8ae6159542a5c276d30d65ebde493b893ac4006331838443fee23961262263b02b1bb398e8a15c7a5cc28d123591f21c42eb277e2d66478d71320a8c0db52a1057c135f444ce3d70406d707a774d4a684d483c524b2b777723564d47504d7648526d5633462a64546e522a562b56324d3f48343e467946703e5647633f686733233f673e4d6b38646664343866652d316165302d343331632d626362632d396539376238376361393830313431383530333537372d343339373030fc73ac03c40c83e1c330776e6bdfb7150c2e8d98fd54acccd4f9316d601a4f784b425e69897d5c211ae017dda4cea94978f4b14d4a26a90851f5288ace85aab2 // [api_public_encryption_key] => // [api_mcryption_key] => 369931f7162926d4082688d3318e46837f1d0f7ef7619790b98bb3bf5bd38877 // [api_url_override] => http://localhost/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $plugin_settings_record , '$plugin_settings_record' ) ; // ------------------------------------------------------------------------- // Trim the various copy/pasted stuff stuff in the plugin settings record // (to prevent problems with leading/trailing white space (eg; newlines), // etc - that can sometimes be added when copy/pasting)... // ------------------------------------------------------------------------- $plugin_settings_record['ad_swapper_user_sid'] = trim( $plugin_settings_record['ad_swapper_user_sid'] ) ; $plugin_settings_record['ad_swapper_site_sid'] = trim( $plugin_settings_record['ad_swapper_site_sid'] ) ; $plugin_settings_record['site_registration_key'] = trim( $plugin_settings_record['site_registration_key'] ) ; // $plugin_settings_record['api_public_encryption_key'] = trim( $plugin_settings_record['api_public_encryption_key'] ) ; $plugin_settings_record['api_mcryption_key'] = trim( $plugin_settings_record['api_mcryption_key'] ) ; $plugin_settings_record['api_url_override'] = trim( $plugin_settings_record['api_url_override'] ) ; // ========================================================================= // ad_swapper_user_sid ? // ========================================================================= if ( ! is_string( $plugin_settings_record['ad_swapper_user_sid'] ) || trim( $plugin_settings_record['ad_swapper_user_sid'] ) === '' ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the Ad Swapper Account ID field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/sequential-ids-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\ // question_sequential_id( // $candidate_sid // ) // - - - - - - - - - - - - // Determines whether or not $candidate_sid looks like a sequential ID // as generated by (eg):- // get_new_sequential_id() // get_new_sequential_id_thats_unique_in_dataset() // // or not. And returns TRUE or FALSE accordingly. // // In other words, $candidate_sid must be something like (eg):- // "dczv-mwhk" // "9npd-xd2h" // "pxx4-4942-9vwm" // "2n43-3dny-dykm" // etc... // ------------------------------------------------------------------------- $ok = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\question_sequential_id( $plugin_settings_record['ad_swapper_user_sid'] ) ; // ------------------------------------------------------------------------- if ( $ok !== TRUE ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the Ad Swapper Account ID field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ========================================================================= // site_registration_key ? // ========================================================================= if ( ! is_string( $plugin_settings_record['site_registration_key'] ) || trim( $plugin_settings_record['site_registration_key'] ) === '' ) { return << Your plugin settings appear to be corrupt. Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- if ( ! ctype_xdigit( $plugin_settings_record['site_registration_key'] ) ) { return << Your plugin settings appear to be corrupt. Detected in:  \\{$ns}\\{$fn}() EOT; } // ========================================================================= // api_mcryption_key ? // ========================================================================= if ( ! is_string( $plugin_settings_record['api_mcryption_key'] ) || trim( $plugin_settings_record['api_mcryption_key'] ) === '' ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the API Encyption/Decryption Key field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- if ( \strlen( $plugin_settings_record['api_mcryption_key'] ) !== 64 || ! \ctype_xdigit( $plugin_settings_record['api_mcryption_key'] ) ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the API Encyption/Decryption Key field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ========================================================================= // ad_swapper_site_sid ? // ========================================================================= if ( ! is_string( $plugin_settings_record['ad_swapper_site_sid'] ) || trim( $plugin_settings_record['ad_swapper_site_sid'] ) === '' ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the Ad Swapper Site ID field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- $ok = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\question_sequential_id( $plugin_settings_record['ad_swapper_site_sid'] ) ; // ------------------------------------------------------------------------- if ( $ok !== TRUE ) { return << Please run the "Maintain Plugin Settings" option (on the Ad Swapper plugin Main Menu) - and fill in the Ad Swapper Site ID field as instructed. Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $plugin_settings_record = Array( // [created_server_datetime_utc] => 1418445053 // [last_modified_server_datetime_utc] => 1418445053 // [key] => bcf39324-f329-4924-b0d2-48912f67059f-1418445053-729167-1354 // [ad_swapper_user_sid] => nddn-kmzv // [ad_swapper_site_sid] => ndd2-kzvh // [site_registration_key] => HWeBEJfebcctlaJf/TrjAyxmeEcjyz8j7QOk18oBSF4X1a03zFEb2taSa9ciI0H8oJShMMgkuYirjlAVmP42UMrvB+WyArjnmyriUr3n+T1PapDF0K2Ku8eDVxrbKmOhzeFoCByU1/q/qh3WT28rjNi4iHg1FgA3LjGLN6PWosOi+vx+jghUxsnw3LAMwsin8JxtgDWG+PL1vXd0674+rqEJVj4qN4S8lzkYX2gVsWQAOy1VuIKovIgMXivcN5XrTtnrmo445b/M9ckXBrVR8e6Ou5icOos5+Jg148IZC0B3AYPwvX4d1H+ci5nBta6aEqWUSiIza6Xkw1JVc10m7S1Qt8VTAvt8nslnHlpw+ZKgmafD2iIU3fGNDkp49zn8ZdhSAi/Wv2DxM7F/c5+rHsQ8V3aNQPppVroneCr9u/ObraS7/qB97b2yXpe0hqOWWjVchSBp6TaRw70N/5fk3c9VAgVHZy5y1snze+zs8xW4nI8IoQSfKlOu9Q0b92A/U1dgGYm02new71YIZMRC7xsNS+ZHnK+SZ8FCMsmxUlXPu6QxV3dgOVUCVg4ADSDn5MJTpjHSRkgxz8ImzQ//1qeSv8X2msJK3Nm7GTMwgpgq2jiqJHUhXqUnqz6YCfMSPKE3J8WlMbNcylu3g507p33ThKITHopBGdIdLXXgRxV4WDcyP2g0WEx6QHY8VD52WiZDeUoybSU8I3pNPUoqTT1kenZuTCYjPz4yazxIeXBMWCpNcHg0UEdLRj1ZVz9UZWY5NzhhYmQtMmFmYy00OGIyLWIzZmUtZjM0NGJjNWRkYTc4MTQxODQ0NDk1OS02ODg0NDIxvcWfw3mnb6+EDDqISwzdzKkxMcEGJduWdREl3JYcP7pJM7FUiO1HCi8+8MzM9r/9BsED9A/GILeKwN3hzuBI // [api_public_encryption_key] => // [api_mcryption_key] => eb5776b9b8c8e2c4e16e37a593875d078ceb30b90dc36dc82483d8d997c21d3e // [api_url_override] => http://localhost/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $plugin_settings_record ) ; // ------------------------------------------------------------------------- // NOTE! // ===== // The Plugin Settings AREN'T sent to the central site directly (except // for the "Ad Swapper User Id"). The other keys etc are just used for // hashing and encryption of the data to be sent. // ------------------------------------------------------------------------- // ========================================================================= // Local Plugin Versions... // ========================================================================= $local_plugin_version_number = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\get_plugin_full_version_number_with_dots() ; // Eg: "0.1.123" // ========================================================================= // Create and encrypt the API Data... // ========================================================================= $api_data = array( 'api_name' => $api_name , 'account_sid' => $plugin_settings_record['ad_swapper_user_sid'] , 'site_sid' => $plugin_settings_record['ad_swapper_site_sid'] , 'calling_plugin_version_number' => $local_plugin_version_number , 'api_specific_data' => $api_data ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $api_data ) ; // ------------------------------------------------------------------------- // NOTE! // ===== // To encrypt the API Data, we must first convert it from array to string. // // This would normally be done with PHP's "serialize()" function. But in // the matching "unserialize()" function, we find this note:- // // "Warning // // Do not pass untrusted user input to unserialize(). Unserialization // can result in code being loaded and executed due to object // instantiation and autoloading, and a malicious user may be able to // exploit this. Use a safe, standard data interchange format such as // JSON (via json_decode() and json_encode()) if you need to pass // serialized data to the user." // // So we use "json_encode()"/"json_decode()" instead. // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // string json_encode ( mixed $value [, int $options = 0 [, int $depth = 512 ]] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Returns a string containing the JSON representation of value. // // value // The value being encoded. Can be any type except a resource. // // All string data must be UTF-8 encoded. // // Note: PHP implements a superset of JSON - it will also encode // and decode scalar types and NULL. The JSON standard only // supports these values when they are nested inside an // array or an object. // // options // Bitmask consisting of // JSON_HEX_QUOT // JSON_HEX_TAG // JSON_HEX_AMP // JSON_HEX_APOS // JSON_NUMERIC_CHECK // JSON_PRETTY_PRINT // JSON_UNESCAPED_SLASHES // JSON_FORCE_OBJECT // JSON_UNESCAPED_UNICODE. // // The behaviour of these constants is described on the JSON // constants page. // // depth // Set the maximum depth. Must be greater than zero. // // Returns a JSON encoded string on success or FALSE on failure. // // (PHP 5 >= 5.2.0, PECL json >= 1.2.0) // // CHANGELOG // Version Description // 5.5.0 depth parameter was added. // 5.4.0 JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and // JSON_UNESCAPED_UNICODE options were added. // 5.3.3 JSON_NUMERIC_CHECK option was added. // 5.3.0 The options parameter was added. // ------------------------------------------------------------------------- $api_data_json = \json_encode( $api_data ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $api_data_json ) ; // ------------------------------------------------------------------------- // Encrypt with MCRYPT... // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/mcrypt-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mcryptSupport\ // mc_encrypt( $data_to_encrypt , $key ) // - - - - - - - - - - - - - - - - - - - // $data_to_encrypt is assumed to be a serialised or json-encoded string. // $key must be a 32-byte random binary string that's been hex-encoded // (and so is now 64 bytes). // (See the Warning in "unserialize()" - which says JSON safer.) // Returns the encypted data as a base64 encoded string. // ------------------------------------------------------------------------- $api_data_encrypted = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mcryptSupport\mc_encrypt( $api_data_json , $plugin_settings_record['api_mcryption_key'] ) ; // ------------------------------------------------------------------------- // HASH the (encypted) API Data (with the Plugin Registration Key)... // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // string hash ( string $algo , string $data [, bool $raw_output = false ] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Generate a hash value (message digest) // // algo // Name of selected hashing algorithm (i.e. "md5", "sha256", // "haval160,4", etc..) // // data // Message to be hashed. // // raw_output // When set to TRUE, outputs raw binary data. FALSE outputs // lowercase hexits. // // RETURN VALUES // Returns a string containing the calculated message digest as // lowercase hexits unless raw_output is set to true in which case the // raw binary representation of the message digest is returned. // // (PHP 5 >= 5.1.2, PECL hash >= 1.1) // // CHANGELOG // Version Description // 5.4.0 The tiger algorithm now uses big-endian byte ordering. // ------------------------------------------------------------------------- $algo = 'sha512' ; $data = $plugin_settings_record['site_registration_key'] . $api_data_encrypted ; $raw_output = FALSE ; // ------------------------------------------------------------------------- $checksum = \hash( $algo , $data , $raw_output ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $checksum ) ; // ------------------------------------------------------------------------- // HASH the SITE ID (with the Plugin Registration Key)... // ------------------------------------------------------------------------- $algo = 'sha512' ; $data = $plugin_settings_record['site_registration_key'] . $plugin_settings_record['ad_swapper_site_sid'] ; $raw_output = FALSE ; // ------------------------------------------------------------------------- $hashed_site_sid = \hash( $algo , $data , $raw_output ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $hashed_site_id ) ; // ------------------------------------------------------------------------- // Create the POST DATA to send... // ------------------------------------------------------------------------- $post_data = array( 'site_key' => $hashed_site_sid , 'api_data' => $api_data_encrypted , 'checksum' => $checksum ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $post_data ) ; // ========================================================================= // Make the POST request to the Ad Swapper Central site... // ========================================================================= // ------------------------------------------------------------------------- // wp_remote_post( $url , $args ) // - - - - - - - - - - - - - - - // Retrieves a URL using the HTTP POST method, returning results in an // array. Results include HTTP headers and content. // // See wp_remote_get() for using the HTTP GET method. // // NOTE: Request cookies need to be passed as an array of WP_Http_Cookie // objects. See example below. // // $url // (string) (required) Universal Resource Locator (URL). // // Default: None // // $args // (array) (optional) Optional. See HTTP_API#Other_Arguments for // argument details. // // Default: array( // 'method' => 'POST' , // 'timeout' => 5 , // 'redirection' => 5 , // 'httpversion' => '1.0; , // 'blocking' => true , // 'headers' => array() , // 'body' => null , // 'cookies' => array() // ) // // RETURN VALUES // (array|WP_Error) // Array of results including HTTP headers or WP_Error if the request // failed. // // For example:- // // $result = Array( // [headers] => Array( // [date] => Thu, 30 Sep 2010 15:16:36 GMT // [server] => Apache // [x-powered-by] => PHP/5.3.3 // [x-server] => 10.90.6.243 // [expires] => Thu, 30 Sep 2010 03:16:36 GMT // [cache-control] => Array( // [0] => no-store, no-cache, must-revalidate // [1] => post-check=0, pre-check=0 // ) // [vary] => Accept-Encoding // [content-length] => 1641 // [connection] => close // [content-type] => application/php // ) // [body] => "This is a website!" // [response] => Array( // [code] => 200 // [message] => OK // ) // [cookies] => Array() // ) // // EXAMPLE // // Post data should be sent in the body as an array. Eg (passing post // data): // // $response = wp_remote_post( $url, array( // 'method' => 'POST' , // 'timeout' => 45 , // 'redirection' => 5 , // 'httpversion' => '1.0' , // 'blocking' => true , // 'headers' => array() , // 'body' => array( 'username' => 'bob', 'password' => '1234xyz' ) , // 'cookies' => array() // ) ) ; // // if ( is_wp_error( $response ) ) { // $error_message = $response->get_error_message() ; // echo "Something went wrong: $error_message" ; // } else { // echo 'Response:
';
    //         print_r( $response );
    //         echo '
'; // } // // In the example above, $response['body'] will contain the actual page // content returned by the server. // // CHANGE LOG // Since: 2.7.0 // ------------------------------------------------------------------------- //http://localhost/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php $url = trim( $plugin_settings_record['api_url_override'] ) ; // ------------------------------------------------------------------------- if ( $url === '' ) { $url = 'http://adswapper.net/api.php' ; } // ------------------------------------------------------------------------- if ( ( array_key_exists( 'HTTP_HOST' , $_SERVER ) && $_SERVER['HTTP_HOST'] === 'localhost' ) || ( array_key_exists( 'SERVER_ADDR' , $_SERVER ) && $_SERVER['SERVER_ADDR'] === '127.0.0.1' ) ) { echo << Contacting Ad Swapper Central Site at:-
{$url}
EOT; } // ------------------------------------------------------------------------- $args = array( 'method' => 'POST' , 'headers' => array() , 'body' => $post_data , 'cookies' => array() ) ; // ------------------------------------------------------------------------- $response = \wp_remote_post( $url , $args ) ; // ------------------------------------------------------------------------- if ( \is_wp_error( $response ) ) { $msg = $response->get_error_message() ; return <<{$msg} Detected in:  \\{$ns}\\{$fn}() EOT; } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $response = Array( // // [headers] => Array( // [date] => Mon, 24 Nov 2014 06:30:39 GMT // [server] => Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1 // [x-powered-by] => PHP/5.3.8 // [content-length] => 287 // [connection] => close // [content-type] => text/html // ) // // [body] => "Fatal error: Call to undefined function greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr() in /opt/lampp/htdocs/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php on line 37" // // [response] => Array( // [code] => 200 // [message] => OK // ) // // [cookies] => Array() // // [filename] => // // ) // // ------------------------------------------------------------------------- //echo '

-------------------------------

' ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $response , '$response' ) ; //echo '

-------------------------------

' ; if ( $response['response']['code'] !== 200 ) { $safe_code = htmlentities( $response['response']['code'] ) ; $safe_message = htmlentities( $response['response']['message'] ) ; return <<Response code {$safe_code}: {$safe_message} Detected in:  \\{$ns}\\{$fn}() EOT; } // ========================================================================= // Return the Central site's response to the caller... // ========================================================================= // ------------------------------------------------------------------------- // "--OK--" // ------------------------------------------------------------------------- if ( $response['body'] === '--OK--' ) { return TRUE ; } // ------------------------------------------------------------------------- // ERROR/DEBUGGING MESSAGE ? // ------------------------------------------------------------------------- $token = '--OK-WITH-DATA--' ; // ------------------------------------------------------------------------- if ( strlen( $response['body'] ) < strlen( $token ) || substr( $response['body'] , 0 , strlen( $token ) ) !== $token ) { return $response['body'] ; } // ------------------------------------------------------------------------- // "--OK-WITH-DATA--" // ------------------------------------------------------------------------- $api_passback_data = substr( $response['body'] , strlen( $token ) ) ; // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/string-utils.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ // hex_decode( $input_string ) // - - - - - - - - - - - - - - // Decodes a hex encoded PHP string. For example:- // // hex_decode( '414243313233' ) // ==> "ABC123" // // hex_decode( '54686520717569636b2062726f776e20666f782e2e2e' ) // ==> "The quick brown fox..." // // NOTES! // ------ // 1. hex_decode() will handle all HEX values, from HEX "00" to // HEX "ff" ("FF"). Ie:- // // hex_decode( '000102fdfeff' ) // ==> chr(0) . chr(1) . chr(2) . chr(253) . chr(254) . chr(255) // // In other words, hex_decode() will decode HEX strings that // contain BINARY data. // // 2. The "a" to "f" characters in the encoded string may be in either // UPPER or lower case. // // 3. hex_decode() is normally used to decode a string encoded by // hex_encode(). // // 4. From the PHP Manual, "Strings" section... // // "A string is series of characters. Before PHP 6, a character // is the same as a byte. That is, there are exactly 256 // different characters possible. This also implies that PHP // has no native support of Unicode. See utf8_encode() and // utf8_decode() for some basic Unicode functionality. // // Note: It is no problem for a string to become very large. // PHP imposes no boundary on the size of a string; the // only limit is the available memory of the computer // on which PHP is running." // ----------------------------------------------------------------------- $api_passback_data = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\hex_decode( $api_passback_data ) ; // ------------------------------------------------------------------------- // require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/mcrypt-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mcryptSupport\ // mc_decrypt( $data_to_encrypt , $key ) // - - - - - - - - - - - - - - - - - - - // $data_to_encrypt is assumed to be a base64 encoded string (as created // by "mc_encrypt()"). // $key must be a 32-byte random binary string that's been hex-encoded // (and so is now 64 bytes). Must also be the same as the $key supplied // to "mc_encrypt()". // Returns the encypted data as an (assumed) serialised or json-encoded // string. // ------------------------------------------------------------------------- $api_passback_data = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mcryptSupport\mc_decrypt( $api_passback_data , $plugin_settings_record['api_mcryption_key'] ) ; // ------------------------------------------------------------------------- // mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Takes a JSON encoded string and converts it into a PHP variable. // // json // The json string being decoded. // // This function only works with UTF-8 encoded strings. // // Note: PHP implements a superset of JSON - it will also encode // and decode scalar types and NULL. The JSON standard only // supports these values when they are nested inside an // array or an object. // // assoc // When TRUE, returned objects will be converted into associative // arrays. // // depth // User specified recursion depth. // // options // Bitmask of JSON decode options. Currently only // JSON_BIGINT_AS_STRING is supported (default is to cast large // integers as floats) // // Returns the value encoded in json in appropriate PHP type. Values true, // false and null are returned as TRUE, FALSE and NULL respectively. NULL is // returned if the json cannot be decoded or if the encoded data is deeper // than the recursion limit. // // (PHP 5 >= 5.2.0, PECL json >= 1.2.0) // ------------------------------------------------------------------------- $assoc = TRUE ; // ------------------------------------------------------------------------- $api_passback_data = \json_decode( $api_passback_data , $assoc ) ; // ------------------------------------------------------------------------- if ( $api_passback_data === NULL ) { return <<{$option_title}) EOT; } else { $option_title = '' ; } // ------------------------------------------------------------------------- $msg = << SITE NOT REGISTERED!

This option{$option_title} WON'T WORK - until you've registered this Ad Swapper plugin site with Ad Swapper Central.  To do this:-

  1. Open this plugin's Maintain Plugin Settings option (in one tab/window).
  2. Go to Ad Swapper Central (http://www.adswapper.net/) (in another tab/window).
  3. If you don't have an account (at Ad Swapper Central), then register one (and wait for your confirmation email).  The confirmation email will provide your account login details.
  4. Login (at Ad Swapper Central).
  5. Start the Ad Swapper Central A/C Mgr (v#.#.#) plugin (from the Ad Swapper Central account dashboard).
  6. Click the Add/Edit/Delete (This Account's) Sites option.
  7. Click Add Site Registration - and follow the instructions to register your Ad Swapper plugin site with your Ad Swapper Central account (and local plugin).

You should then be able to (successfully) run this option again.

EOT; // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/string-utils.php' ) ; // ------------------------------------------------------------------------- $msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_orange_message( $msg ) ; // ------------------------------------------------------------------------- return \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_one_line( $msg ) ; // ------------------------------------------------------------------------- } /* // ============================================================================= // get_openssl_errors() // ============================================================================= function get_openssl_errors() { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_updateCentralSite\ // get_openssl_errors() // - - - - - - - - - - - // Returns any "openssl" errors - as a (possibly empty) STRING // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // string openssl_error_string ( void ) // - - - - - - - - - - - - - - - - - - // openssl_error_string() returns the last error from the openSSL library. // // Error messages are queued, so this function should be called multiple // times to collect all of the information. The last error will be the most // recent one. // // Returns an error message string, or FALSE if there are no more error // messages to return. // // (PHP 4 >= 4.0.6, PHP 5) // ------------------------------------------------------------------------- $out = '' ; $comma = '' ; while ( TRUE ) { $msg = \openssl_error_string() ; if ( $msg === FALSE ) { break ; } $msg = trim( $msg ) ; if ( $msg !== '' ) { $out .= $comma . $msg ; $comma = '
' ; } } if ( $out !== '' ) { $out = <<{$out} EOT; } return $out ; // ------------------------------------------------------------------------- } */ // ============================================================================= // question_ad_swapper_user_sid() // ============================================================================= /* function question_ad_swapper_user_sid( $core_plugapp_dirs , $candidate_ad_swapper_user_sid ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_updateCentralSite\ // question_ad_swapper_user_sid( // $core_plugapp_dirs , // $candidate_ad_swapper_user_sid // ) // - - - - - - - - - - - - - - - - - - - // An Ad Swapper User ID is like (eg):- // "x2v7-kyhw-5xk7-43rm-r6w9-kt9y" // // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/great-kiwi-passwords.php' ) ; // ----------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\ // question_grouped_random_password( // $candidate_password , // $options = array() // ) // - - - - - - - - - - - - - - - - - // Checks whether the $candidate_password is a grouped random password // like:- // k53t-xc92-v7k3 // etc // // Allowed password characters are those in:- // GREAT_KIWI_ALLOWED_PASSWORD_CHARACTERS // // Currently these are all the ASCII alphanumeric characters but:- // 0 1 5 6 8 // A B D E I O Q S U // a b e f i j l o q r s t u // // These are omitted because they're combinations like:- // 0/8/B/D/Q // 1/I/l // 5/S // etc // // that can easily be confused with each other. // // --- // // $options is like (eg):- // // $options = array( // 'number_groups' => 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE // ) // // --- // // NOTE! // ----- // With some combinations, it depends very much on the FONT used (as to // how similar two different characters look). Thus the above rules are // a worst-case set. Stuff is in there if in any common (web) font, // the chance of confusion exists. // // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ----------------------------------------------------------------------- return \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $candidate_ad_swapper_user_sid , $GLOBALS['greatKiwi_byFernTec_adSwapper_local_v0x1x211_adSwapperUserIdOptions'] ) ; // ------------------------------------------------------------------------- } */ /* // ============================================================================= // question_ad_swapper_site_id() // ============================================================================= function question_ad_swapper_site_id( $core_plugapp_dirs , $candidate_ad_swapper_site_id ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_updateCentralSite\ // question_ad_swapper_site_id( // $core_plugapp_dirs , // $candidate_ad_swapper_site_id // ) // - - - - - - - - - - - - - - - - - - - // An Ad Swapper User ID is like (eg):- // "x2v7-kyhw-5xk7-43rm-r6w9-kt9y" // // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/great-kiwi-passwords.php' ) ; // ----------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\ // question_grouped_random_password( // $candidate_password , // $options = array() // ) // - - - - - - - - - - - - - - - - - // Checks whether the $candidate_password is a grouped random password // like:- // k53t-xc92-v7k3 // etc // // Allowed password characters are those in:- // GREAT_KIWI_ALLOWED_PASSWORD_CHARACTERS // // Currently these are all the ASCII alphanumeric characters but:- // 0 1 5 6 8 // A B D E I O Q S U // a b e f i j l o q r s t u // // These are omitted because they're combinations like:- // 0/8/B/D/Q // 1/I/l // 5/S // etc // // that can easily be confused with each other. // // --- // // $options is like (eg):- // // $options = array( // 'number_groups' => 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE // ) // // --- // // NOTE! // ----- // With some combinations, it depends very much on the FONT used (as to // how similar two different characters look). Thus the above rules are // a worst-case set. Stuff is in there if in any common (web) font, // the chance of confusion exists. // // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ----------------------------------------------------------------------- return \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $candidate_ad_swapper_site_id , $GLOBALS['greatKiwi_byFernTec_adSwapper_local_v0x1x211_adSwapperSiteIdOptions'] ) ; // ------------------------------------------------------------------------- } */ /* // ========================================================================= // Get the Ad Swapper Central API URL... // ========================================================================= // ========================================================================= // Send the request using the WordPress HTTP API... // ========================================================================= // ------------------------------------------------------------------------- // wp_remote_post( $url, $args ) // - - - - - - - - - - - - - - - // Retrieves a URL using the HTTP POST method, returning results in an // array. Results include HTTP headers and content. // // See wp_remote_get() for using the HTTP GET method. // // NOTE: Request cookies need to be passed as an array of WP_Http_Cookie // objects. See example below. // // $url // (string) (required) Universal Resource Locator (URL). // Default: None // // $args // (array) (optional) Optional. See HTTP_API#Other_Arguments for // argument details. // // Default: method: POST, timeout: 5, redirection: 5, httpversion: // 1.0, blocking: true, headers: array(), body: null, cookies: // array() // // RETURN VALUES // (array|WP_Error) // Array of results including HTTP headers or WP_Error if the request // failed. // // CHANGE LOG // Since: 2.7.0 // ------------------------------------------------------------------------- $data = array( 'api_function_name' => $api_function_name , 'args' => $args ) // ------------------------------------------------------------------------- $result = wp_remote_post( $url, $args ) // ========================================================================= // That's that! // ========================================================================= } */ /* // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // NOTE! // ===== // The following form of openssl_xxx() encryption doesn't work. // Don't know why! Fails when decrypting at the central server. // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // ------------------------------------------------------------------------- // bool openssl_public_encrypt ( string $data , string &$crypted , mixed $key [, int $padding = OPENSSL_PKCS1_PADDING ] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // openssl_public_encrypt() encrypts data with public key and stores the // result into crypted. Encrypted data can be decrypted via // openssl_private_decrypt(). // // This function can be used e.g. to encrypt message which can be then read // only by owner of the private key. It can be also used to store secure // data in database. // // data // // crypted // This will hold the result of the encryption. // // key // The public key. // // padding // padding can be one of OPENSSL_PKCS1_PADDING, // OPENSSL_SSLV23_PADDING, OPENSSL_PKCS1_OAEP_PADDING, // OPENSSL_NO_PADDING. // // Returns TRUE on success or FALSE on failure. // // (PHP 4 >= 4.0.6, PHP 5) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // NOTE! // ===== // "openssl_public_encrypt()" only accepts very short data block. // // 117 bytes appears to be a reasonably safe max. length. See:- // https://www.virendrachandak.com/techtalk/encryption-using-php-openssl/ // ------------------------------------------------------------------------- $api_data_encrypted = '' ; // ------------------------------------------------------------------------- $pointer = 0 ; $bytes_left = \strlen( $api_data_json ) ; $chunk_len = 117 ; // ------------------------------------------------------------------------- $encrypted_chunk = '' ; // ------------------------------------------------------------------------- while ( $bytes_left > 0 ) { // --------------------------------------------------------------------- $chunk = \substr( $api_data_json , $pointer , \min( $bytes_left , $chunk_len ) ) ; //echo '
' , $chunk , ' --- ' , $bytes_left , ' bytes left' ; // --------------------------------------------------------------------- $ok = \openssl_public_encrypt( $chunk , $encrypted_chunk , $plugin_settings_record['api_public_encryption_key'] ) ; // --------------------------------------------------------------------- if ( $ok !== TRUE ) { $msg = << Sorry, but we were unable to encrypt the data to be sent to Ad Swapper Central. Detected in:  \\{$ns}\\{$fn}() EOT; return array( $msg ) ; } // --------------------------------------------------------------------- echo '
' , strlen( $encrypted_chunk ) ; $api_data_encrypted .= $encrypted_chunk ; // --------------------------------------------------------------------- $pointer += $chunk_len ; $bytes_left -= $chunk_len ; // --------------------------------------------------------------------- } */ /* // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // NOTE! // ===== // The following form of openssl_xxx() encryption doesn't work either. // Don't know why! Fails when decrypting at the central server. // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // ------------------------------------------------------------------------- // resource openssl_pkey_get_public ( mixed $certificate ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - // openssl_get_publickey() extracts the public key from certificate and // prepares it for use by other functions. // // certificate // certificate can be one of the following: // // o An X.509 certificate resource // o A string having the format file://path/to/file.pem. The // named file must contain a PEM encoded certificate/public key // (it may contain both). // o A PEM formatted public key. // // Returns a positive key resource identifier on success, or FALSE on error. // // (PHP 4 >= 4.2.0, PHP 5) // ------------------------------------------------------------------------- // require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/string-utils.php' ) ; // ----------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ // hex_decode( $input_string ) // - - - - - - - - - - - - - - // Decodes a hex encoded PHP string. For example:- // // hex_decode( '414243313233' ) // ==> "ABC123" // // hex_decode( '54686520717569636b2062726f776e20666f782e2e2e' ) // ==> "The quick brown fox..." // // NOTES! // ------ // 1. hex_decode() will handle all HEX values, from HEX "00" to // HEX "ff" ("FF"). Ie:- // // hex_decode( '000102fdfeff' ) // ==> chr(0) . chr(1) . chr(2) . chr(253) . chr(254) . chr(255) // // In other words, hex_decode() will decode HEX strings that // contain BINARY data. // // 2. The "a" to "f" characters in the encoded string may be in either // UPPER or lower case. // // 3. hex_decode() is normally used to decode a string encoded by // hex_encode(). // // 4. From the PHP Manual, "Strings" section... // // "A string is series of characters. Before PHP 6, a character // is the same as a byte. That is, there are exactly 256 // different characters possible. This also implies that PHP // has no native support of Unicode. See utf8_encode() and // utf8_decode() for some basic Unicode functionality. // // Note: It is no problem for a string to become very large. // PHP imposes no boundary on the size of a string; the // only limit is the available memory of the computer // on which PHP is running." // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ // hex_clean( // $instr // $question_display_bad_chars = FALSE // ) // - - - - - - - - - - - - - - - - - - - - // Removes all non-hex chars from the input string. Useful for (eg) // hex strings entered into a text or textarea field, that may have been // saved with unstripped leading/trailing space, for example. // // RETURNS // $cleaned_string STRING // ----------------------------------------------------------------------- $public_key_id = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\hex_clean( $plugin_settings_record['api_public_encryption_key'] ) ; // ------------------------------------------------------------------------- $public_key_id = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\hex_decode( $public_key_id ) ; // ------------------------------------------------------------------------- $public_key_id = \openssl_pkey_get_public( $public_key_id ) ; // ------------------------------------------------------------------------- if ( $public_key_id === FALSE ) { $msg = get_openssl_errors() ; $msg = <<= 4.0.4, PHP 5) // // EXAMPLE // // $data is assumed to contain the data to be sealed // // fetch public keys for our recipients, and ready them // $fp = fopen("/src/openssl-0.9.6/demos/maurice/cert.pem", "r"); // $cert = fread($fp, 8192); // fclose($fp); // $pk1 = openssl_get_publickey($cert); // // Repeat for second recipient // $fp = fopen("/src/openssl-0.9.6/demos/sign/cert.pem", "r"); // $cert = fread($fp, 8192); // fclose($fp); // $pk2 = openssl_get_publickey($cert); // // seal message, only owners of $pk1 and $pk2 can decrypt $sealed with keys // $ekeys[0] and $ekeys[1] respectively. // openssl_seal($data, $sealed, $ekeys, array($pk1, $pk2)); // // free the keys from memory // openssl_free_key($pk1); // openssl_free_key($pk2); // // BETTER EXAMPLE FROM:- // http://blog.local.ch/en/2007/10/29/openssl-php-to-java/ // // $dir = '/path/to/openssl/certificates'; // $data = "A secret message for Bob"; // the data to encrypt // // // Get the public key // $publicKey = openssl_get_publickey(file_get_contents("$dir/pubkey_rsa.pem")); // // // encrypt the data // openssl_seal($data, $sealed, $ekeys, array($publicKey)); // // openssl_free_key($publicKey); // // $sealed = base64_encode($sealed); // $Xevk = base64_encode($ekeys[0]); // // // Now do the round trip for example - decrypt using the private key // $privateKey = openssl_get_privatekey(file_get_contents("$dir/privkey_rsa.pem")); // // openssl_open(base64_decode($sealed), $opened, base64_decode($Xevk), $privateKey) // or die(openssl_error_string()); // // openssl_free_key($privateKey); // ------------------------------------------------------------------------- $length_of_sealed_data = \openssl_seal( $api_data_json , $api_data_encrypted , $envelope_keys , array( $public_key_id ) ) ; // ------------------------------------------------------------------------- if ( $length_of_sealed_data === FALSE ) { $msg = get_openssl_errors() ; $msg = << Sorry, but we were unable to encrypt the data to be sent to Ad Swapper Central. {$msg} Detected in:  \\{$ns}\\{$fn}() EOT; return array( $msg ) ; } */ // ============================================================================= // That's that! // =============================================================================