\
// get_update_central_site_page_html(
// $core_plugapp_dirs ,
// $applications_dataset_and_view_definitions_etc ,
// $all_custom_pages ,
// $this_custom_page ,
// $question_front_end
// )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Updates the Ad Swapper Central site (with this site's Ad Swapper site
// details and ads, etc.
//
// Returns the "Update Central Site" page HTML.
//
// RETURNS
// o On SUCCESS
// $page_html STRING
// (The HTML for the page to be displayed.)
//
// o On FAILURE
// ARRAY( $error_message ) STRING
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// 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' ) ;
// =========================================================================
// Init.
// =========================================================================
$ns = __NAMESPACE__ ;
$fn = __FUNCTION__ ;
// -------------------------------------------------------------------------
// \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\
// get_page_header(
// $page_title ,
// $caller_apps_includes_dir ,
// $question_front_end
// )
// - - - - - - - - - - - - - - - - - - -
// Returns the page header HTML - for the currently running plugin - and
// with the specified title.
//
// Dies() on error.
// -------------------------------------------------------------------------
$page_title = $this_custom_page['general_title'] ;
$caller_apps_includes_dir = $core_plugapp_dirs['plugins_includes_dir'] ;
$page_header = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\get_page_header(
$page_title ,
$caller_apps_includes_dir ,
$question_front_end
) ;
// -------------------------------------------------------------------------
if ( array_key_exists(
'sync_step' ,
$_GET
)
&&
$_GET['sync_step'] === '1'
) {
$question_synchronising = TRUE ;
} else {
$question_synchronising = FALSE ;
}
// -------------------------------------------------------------------------
$sync_output = '' ;
// =========================================================================
// Support Routines...
// =========================================================================
require_once( dirname( dirname( dirname( __FILE__ ) ) ) . '/api/api-call-support.php' ) ;
// =========================================================================
// Load the Ad Swapper datasets...
// =========================================================================
require_once( dirname( dirname( dirname( __FILE__ ) ) ) . '/includes/datasets-support.php' ) ;
// -------------------------------------------------------------------------
// \greatKiwi_byFernTec_adSwapper_local_v0x1x211_datasetSupport\
// get_ad_swapper_dataset_records(
// $core_plugapp_dirs ,
// $question_front_end ,
// )
// - - - - - - - - - - - - - - -
// Returns the CACHED Ad Swapper dataset records.
//
// RETURNS:-
//
// On FAILURE
// $error_message STRING
//
// On SUCCESS
// array(
// $app_defs_directory_tree ,
// $applications_dataset_and_view_definitions_etc ,
// $all_application_dataset_definitions ,
// $loaded_datasets
// )
//
// Where:-
//
// $loaded_datasets = Array(
//
// [ad_swapper_impressions] => Array(
// [title] => Impressions
// [records] => Array()
// [key_field_slug] => key
// [record_indices_by_key] => Array()
// )
//
// [ad_swapper_settings] => Array(
// [title] => Settings
// [records] => Array(
// [0] => Array(
// [created_server_datetime_utc] => 1416388978
// [last_modified_server_datetime_utc] => 1416388978
// [key] => c885e81e-4af9-40bd-a485-34c9d835d9e5-1416388978-679287-1131
// [api_url_override] => http://localhost/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php
// )
// )
// [key_field_slug] => key
// [record_indices_by_key] => Array(
// [c885e81e-4af9-40bd-a485-34c9d835d9e5-1416388978-679287-1131] => 0
// )
// )
//
// [ad_swapper_plugin_settings] => Array(
// [title] => Plugin Settings
// [records] => Array(
// [0] => Array(
// [created_server_datetime_utc] => 1421887967
// [last_modified_server_datetime_utc] => 1421887967
// [key] => 7dd6c89c-6ac1-4b07-9851-be51d6219420-1421887967-696176-1480
// [ad_swapper_user_sid] => 2gkw-vmcz
// [ad_swapper_site_sid] => 2kmv-hzgc
// [site_unique_key] => 2222-2222-2222-2222
// [site_registration_key] => 675ed35f6c108...7a78fe029d
// [api_public_encryption_key] =>
// [api_mcryption_key] => bc502c56...bb9749691a
// [api_url_override] => http://localhost/plugdev/.../api-call-handler.php
// )
// )
// [key_field_slug] => key
// [record_indices_by_key] => Array(
// [7dd6c89c-6ac1-4b07-9851-be51d6219420-1421887967-696176-1480] => 0
// )
// )
//
// [ad_swapper_site_profile] => Array(
// [title] => Site Profile
// [records] => Array(
// [0] => Array(
// [created_server_datetime_utc] => 1416718948
// [last_modified_server_datetime_utc] => 1416718948
// [key] => 9475e467-59b6-4f6d-9f32-5413e2b07c4e-1416718948-108185-1163
// [site_owners_ad_swapper_user_sid] => z4v2-mkcx-wh79-yg3n
// [site_url] => http://www.example.com
// [site_title] => The Site
// [site_description] =>
// [ads_wanted_description] =>
// [sites_wanted_description] =>
// [categories_available] =>
// [categories_wanted] =>
// )
// )
// [key_field_slug] => key
// [record_indices_by_key] => Array(
// [9475e467-59b6-4f6d-9f32-5413e2b07c4e-1416718948-108185-1163] => 0
// )
// )
//
// )
//
// -------------------------------------------------------------------------
$ad_swapper_dataset_records =
\greatKiwi_byFernTec_adSwapper_local_v0x1x211_datasetSupport\get_ad_swapper_dataset_records(
$core_plugapp_dirs ,
$question_front_end
) ;
// -------------------------------------------------------------------------
if ( is_string( $ad_swapper_dataset_records ) ) {
return array( $ad_swapper_dataset_records ) ;
}
// -------------------------------------------------------------------------
list(
$app_defs_directory_tree ,
$applications_dataset_and_view_definitions_etc ,
$all_application_dataset_definitions ,
$loaded_datasets
) = $ad_swapper_dataset_records ;
// -------------------------------------------------------------------------
// 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
// )
// )
//
// )
//
// -------------------------------------------------------------------------
//$loaded_datasets['ad_swapper_ad_impressions']['records'] = array() ;
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $loaded_datasets , 'LOCAL $loaded_datasets' ) ;
//exit() ;
// =========================================================================
// Prepare the data to be sent to the Ad Swapper Central site...
// =========================================================================
if ( count( $loaded_datasets['ad_swapper_plugin_settings']['records'] ) < 1 ) {
// ---------------------------------------------------------------------
// NO Plugin Settings record yet!
//
// => Site not yet registered with Ad Swapper Central
// ---------------------------------------------------------------------
$dataset_slug = 'ad_swapper_plugin_settings' ;
// ---------------------------------------------------------------------
$msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_apiCallSupport\get_site_not_registered_message(
$core_plugapp_dirs ,
$question_front_end ,
$dataset_slug
) ;
// ---------------------------------------------------------------------
$msg = << Ad Swapper Central Site UPDATED OK!
{$msg}
EOT;
// ---------------------------------------------------------------------
return $msg ;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
$plugin_registration_record_site_unique_key =
$loaded_datasets['ad_swapper_plugin_settings']['records'][0]['site_unique_key']
;
// =========================================================================
// SITE PROFILE
// =========================================================================
if ( count( $loaded_datasets['ad_swapper_site_profile']['records'] ) < 1 ) {
// ---------------------------------------------------------------------
// NO Site Profile record yet!
// ---------------------------------------------------------------------
require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/string-utils.php' ) ;
// ---------------------------------------------------------------------
$msg = <<
{$msg}
EOT;
// ---------------------------------------------------------------------
return \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_one_line( $msg ) ;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
$site_profile_record = $loaded_datasets['ad_swapper_site_profile']['records']['0'] ;
// -------------------------------------------------------------------------
// Here we should have (eg):-
//
// $site_profile_record = Array(
// [created_server_datetime_utc] => 1418445063
// [last_modified_server_datetime_utc] => 1418445063
// [key] => add9f270-9f5b-429a-a264-f0f5c7cc59db-1418445063-977293-1355
// [site_title] => Plugdev
// [home_page_url] => http://localhost/plugdev
// [general_description] =>
// [ads_wanted_description] =>
// [sites_wanted_description] =>
// [categories_available] =>
// [categories_wanted] =>
// [geoip_continents_incl] =>
// [geoip_continents_excl] =>
// [geoip_countries_incl] => NZ
// [geoip_countries_excl] =>
// [geoip_regions_incl] =>
// [geoip_regions_excl] =>
// [geoip_cities_incl] =>
// [geoip_cities_excl] =>
// )
//
// -------------------------------------------------------------------------
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $site_profile_record , 'LOCAL $site_profile_record' ) ;
// -------------------------------------------------------------------------
$site_profile = $site_profile_record ;
// -------------------------------------------------------------------------
unset( $site_profile['created_server_datetime_utc'] ) ;
unset( $site_profile['last_modified_server_datetime_utc'] ) ;
unset( $site_profile['key'] ) ;
// -------------------------------------------------------------------------
unset( $site_profile['max_ads_per_site_per_page'] ) ;
unset( $site_profile['max_repetitions_per_ad_per_page'] ) ;
unset( $site_profile['test_method'] ) ;
unset( $site_profile['test_ip'] ) ;
unset( $site_profile['show_ads_list_reload_buttons'] ) ;
unset( $site_profile['question_manual_update_approval'] ) ;
// -------------------------------------------------------------------------
if ( $site_profile['question_disable_incoming_ads'] ) {
$site_profile['question_disable_incoming_ads'] = 'yes' ;
} else {
$site_profile['question_disable_incoming_ads'] = 'no' ;
}
// -------------------------------------------------------------------------
if ( $site_profile['question_disable_outgoing_ads'] ) {
$site_profile['question_disable_outgoing_ads'] = 'yes' ;
} else {
$site_profile['question_disable_outgoing_ads'] = 'no' ;
}
// -------------------------------------------------------------------------
if ( $site_profile['question_auto_approve_new_ads'] ) {
$site_profile['question_auto_approve_new_ads'] = 'yes' ;
} else {
$site_profile['question_auto_approve_new_ads'] = 'no' ;
}
// -------------------------------------------------------------------------
// require_once( $core_plugapp_dirs['apps_dot_app_dir'] . '/site-and-plugin-status-support.php' ) ;
//
// // -------------------------------------------------------------------------
// // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_siteAndPluginStatusSupport\
// // get_site_and_plugin_status()
// // - - - - - - - - - - - - - -
// // RETURNS
// // On SUCCESS
// // $site_and_plugin_status ARRAY
// //
// // Which array should be like (eg):-
// //
// // $site_and_plugin_status = array(
// // 'last_central_data_retrieval_time_gmt' =>
' , gettype( $api_passback_data ) ;
if ( is_array( $api_passback_data ) ) {
// -------------------------------------------------------------------------
// Here we should have (eg):-
//
// $api_passback_data = Array(
//
// [new_outgoing_ad_global_sids_by_local_key] => Array(
// [542e82a17ed5ab8803342ef00a637fccbe6abd29caec550d16252856c60fa88b] => n3gk-hvmw
// [49c895082a4bc5afad7a262dd1838dcabbfe0b4db4b16359e90cc52873163e10] => 7nmk-hdwv
// )
//
// [new_ad_slot_global_sids_by_local_key] => Array(
// [ab64110189652140b20e35478924a670d56bacf36594d823f88e044a0985e416] => 2dzk-hmvg
// )
//
// )
//
// -------------------------------------------------------------------------
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $api_passback_data ) ;
// =====================================================================
// OUTGOING ADS
// =====================================================================
if ( array_key_exists( 'new_outgoing_ad_global_sids_by_local_key' , $api_passback_data )
&&
is_array( $api_passback_data['new_outgoing_ad_global_sids_by_local_key'] )
&&
count( $api_passback_data['new_outgoing_ad_global_sids_by_local_key'] ) > 0
) {
// -----------------------------------------------------------------
// There are some "new_outgoing_ad_global_sids_by_local_key"...
//
// Are the "global_sids" in this array valid ?
// -----------------------------------------------------------------
// -------------------------------------------------------------------------
// \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...
// -------------------------------------------------------------------------
foreach ( $api_passback_data['new_outgoing_ad_global_sids_by_local_key'] as $this_key => $this_sid ) {
// -------------------------------------------------------------
// if ( trim( (string) $this_id ) === ''
// ||
// ! ctype_digit( (string) $this_id )
// ) {
//
// $msg = <<
Although the Ad Swapper central site was successfully updated:-
Thus, Ad Swapper Central is currently distributing NO ADS for this site (although other Ad Swapper sites ***may*** still be showing your ads that they've previously downloaded - and will continue to do until they Update Local Site again).
To get your ads displaying again; please select at least one country or continent (to target your ads at), from the Maintain This Site's Profile option (on the Ad Swapper plugin Main Menu).
EOT; // ----------------------------------------------------------------- $warning = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_orange_message( $warning ) ; // ----------------------------------------------------------------- $page_body = $warning . '{$page_body}
EOT; // --------------------------------------------------------------------- $page_body = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_error_message( $page_body ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- return <<