diff --git a/cleantalk.php b/cleantalk.php index 7a9147c9a..83a60198a 100644 --- a/cleantalk.php +++ b/cleantalk.php @@ -4,7 +4,7 @@ Plugin Name: Anti-Spam by CleanTalk Plugin URI: https://cleantalk.org Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. - Version: 6.54 + Version: 6.55 Author: CleanTalk - Anti-Spam Protection Author URI: https://cleantalk.org Text Domain: cleantalk-spam-protect @@ -429,6 +429,14 @@ function apbct_write_js_errors($data) apbct_form__learnpress__testSpam(); } +// Appointment Booking Calendar +if ( + apbct_is_plugin_active('appointment-booking-calendar/cpabc_appointments.php') && + Post::getString('cpabc_appointments_post') +) { + apbct_form__appointment_booking_calendar__testSpam(); +} + // OptimizePress if ( apbct_is_plugin_active('op-dashboard/op-dashboard.php') && @@ -616,9 +624,7 @@ function apbct_write_js_errors($data) ! Server::inUri('/favicon.ico') && ! apbct_is_cli() ) { - wp_suspend_cache_addition(true); - apbct_sfw__check(); - wp_suspend_cache_addition(false); + add_action('init', 'apbct_sfw__init_wrapper', 1); } } @@ -840,6 +846,17 @@ function apbct_wpms__delete_blog(WP_Site $old_site) } } +/** + * Wrapper for SpamFireWall check to make if fire on 'init' hook + * @return void + */ +function apbct_sfw__init_wrapper() +{ + wp_suspend_cache_addition(true); + apbct_sfw__check(); + wp_suspend_cache_addition(false); +} + /** * Function for SpamFireWall check */ diff --git a/css/cleantalk-admin-settings-page.min.css b/css/cleantalk-admin-settings-page.min.css index a8d7362fc..dd8f5764f 100644 --- a/css/cleantalk-admin-settings-page.min.css +++ b/css/cleantalk-admin-settings-page.min.css @@ -1 +1 @@ -.apbct_settings-field_title--radio,.apbct_settings-field_title--select,.apbct_settings-field_title--textarea{padding-right:10px;margin:0;font-size:14px;vertical-align:top;width:210px}.apbct_settings-field_content,.apbct_settings-field_title--radio,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}.apbct_settings-page{padding-right:10px}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:70%;padding-bottom:10px}.apbct_settings-field_title--select,.apbct_settings-field_title--textarea{padding-bottom:10px}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-field--api_key{font-size:14pt}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.apbct_setting_textarea{min-width:300px}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:10px 0 0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;text-align:center;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}.apbct_long_desc a,i.animate-spin{color:rgba(120,200,230,1)}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}.--hide{display:none}.apbct_preloader_button{height:15px;margin-left:5px;vertical-align:text-top;display:none}.--invisible{visibility:hidden}.apbct_preloader{height:1em;width:1em;margin-left:.5em;display:inline-block}.key_changed_success,.key_changed_sync{font-size:1.5em;line-height:2em;vertical-align:middle}.--upper-case{text-transform:uppercase}#cleantalk-modal-content{text-align:center}#cleantalk-modal-content>*{display:block;width:100%}button.ct_support_link{border:none;background:0 0;color:#666;text-decoration:underline;cursor:pointer}.apbct-btn-as-link{padding:0;margin:0;vertical-align:baseline;color:gray;border:0;border-bottom:1px solid;cursor:pointer}#apbct-account-email[contenteditable=true]{padding:6px;background-color:#fff;border:1px solid #ccc}button[value=save_changes]:disabled{color:#2271b1;border-color:#2271b1;background:#f6f7f7}#apbct_settings__advanced_settings{position:relative}#apbct_settings__advanced_settings_inner{width:70%}#apbct_hidden_section_nav{position:absolute;top:0;right:20px}#apbct_settings__after_advanced_settings{margin-bottom:20px;width:70%}#apbct_settings__button_section{position:fixed;z-index:9999;width:100%;padding-bottom:40px}.apbct_highlighted{outline-offset:5px;outline-color:red;outline-width:3px!important;outline-style:solid!important}.apbct_notice_inner{display:flex;margin-top:10px!important}.apbct_notification__advanced_settings{margin:20px 0;font-weight:400}.apbct_settings_top_info__div{float:right;padding:0 20px 0 0;font-size:13px;position:relative}.apbct_settings_top_info__p{padding:0;margin:2px}.apbct_settings_top_info__btn{display:inline-flex;gap:10px}.apbct_hidden_section_nav_mob_btn{display:none;background-image:url(images/menu.svg);background-repeat:no-repeat;background-size:contain;background-position-y:center}.apbct_hidden_section_nav_mob_btn-close{display:none}@media (max-width:768px){.apbct_settings_top_info__btn{display:inline-grid;width:100%;gap:5px}#apbct_settings__advanced_settings_inner,#apbct_settings__after_advanced_settings,.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:100%}.apbct_settings_top_info__sub_btn .apbct_bottom_links--left,.apbct_settings_top_info__sub_btn .apbct_bottom_links--other{margin-left:0;margin-right:0}#apbct_hidden_section_nav ul{display:none;background-color:#dadee3bd;margin:0;padding:10px;border-radius:3px}#apbct_hidden_section_nav{right:0;min-width:167px}.apbct_setting_radio::before{height:6px!important;width:6px!important;margin:4px!important}.apbct_setting_checkbox::before{height:15px!important;width:15px!important;margin:0 -.05rem!important}.apbct_setting_checkbox,.apbct_setting_radio{height:16px!important;width:16px!important}.apbct_hidden_section_nav_mob_btn{display:block;width:32px;height:28px;right:-120px;position:relative}.apbct_hidden_section_nav_mob_btn-close{display:block;position:relative;float:right;width:20px;height:22px;top:-5px;right:-5px;background-image:url(images/cancel.svg);background-repeat:no-repeat;background-size:contain;background-position-y:center;text-align:center}.apbct_long_desc{left:-2%!important;max-width:95%;margin-top:10%}.apbct_long_desc__angle{display:none}}.apbct_settings_top_info__sub_btn{display:flex;flex-wrap:wrap;gap:10px;margin:15px 0} \ No newline at end of file +.apbct_settings-field_title--radio,.apbct_settings-field_title--select,.apbct_settings-field_title--textarea{padding-right:10px;margin:0;font-size:14px;vertical-align:top;width:210px}.apbct_settings-field_content,.apbct_settings-field_title--radio,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}.apbct_settings-page{padding-right:10px}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:70%;padding-bottom:10px}.apbct_settings-field_title--select,.apbct_settings-field_title--textarea{padding-bottom:10px}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.apbct_setting_textarea{min-width:300px}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:10px 0 0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#cleantalk-modal-content,.ct_rate_block{text-align:center}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}.apbct_long_desc a,i.animate-spin{color:rgba(120,200,230,1)}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}.--hide{display:none}.apbct_preloader_button{height:15px;margin-left:5px;vertical-align:text-top;display:none}.--invisible{visibility:hidden}.apbct_preloader{height:1em;width:1em;margin-left:.5em;display:inline-block}.key_changed_success,.key_changed_sync{font-size:1.5em;line-height:2em;vertical-align:middle}.--upper-case{text-transform:uppercase}#cleantalk-modal-content>*{display:block;width:100%}button.ct_support_link{border:none;background:0 0;color:#666;text-decoration:underline;cursor:pointer}.apbct-btn-as-link{padding:0;margin:0;vertical-align:baseline;color:gray;border:0;border-bottom:1px solid;cursor:pointer}#apbct-account-email[contenteditable=true]{padding:6px;background-color:#fff;border:1px solid #ccc}button[value=save_changes]:disabled{color:#2271b1;border-color:#2271b1;background:#f6f7f7}#apbct_settings__advanced_settings{position:relative}#apbct_settings__advanced_settings_inner{width:70%}#apbct_hidden_section_nav{position:absolute;top:0;right:0;width:200px}#apbct_hidden_section_nav ul{z-index:9999;width:100%;top:40px}.apbct_settings__position_main_save_button{text-align:right;margin-right:40px}#apbct_settings__after_advanced_settings{margin-bottom:20px;width:70%}#apbct_settings__button_section{position:static;z-index:9999;padding-bottom:40px;bottom:0}.apbct_highlighted{outline-offset:5px;outline-color:red;outline-width:3px!important;outline-style:solid!important}.apbct_notice_inner{display:flex;margin-top:10px!important}.apbct_notification__advanced_settings{margin:20px 0;font-weight:400}.apbct_settings_top_info__div{float:right;padding:0 20px 0 0;font-size:13px;position:relative}.apbct_settings_top_info__p{padding:0;margin:2px}.apbct_settings_top_info__btn{display:inline-flex;gap:10px}.apbct_hidden_section_nav_mob_btn{display:none;background-image:url(images/menu.svg);background-repeat:no-repeat;background-size:contain;background-position-y:center}.apbct_hidden_section_nav_mob_btn-close{display:none}.apbct_settings__footer{background:#c2c2c2;position:absolute;left:0;padding-bottom:30px;padding-left:21px;z-index:-1}.apbct_settings_top_info__sub_btn{display:flex;flex-wrap:wrap;gap:10px;margin:15px 0}.apbct_settings__key_line{display:flex;align-items:center;justify-content:flex-start;flex-direction:row}.apbct_settings__key_line__elements{margin-right:10px}.apbct_setting__key_line__buttons{margin:0}.apbct_setting__key_line__get_key_manual_chunk{margin:10px 0;border:1px solid #d3d3d3;border-radius:3px;padding:10px;background:#FFF}.apbct_settings__key_line__service_block{margin-left:10px}#apbct_settings__public_offer{margin-top:10px;display:flex;align-items:center}#cleantalk_apikey_wrapper{max-width:65%}.apcbt_contact_data_encoder__line{max-width:70%;display:flex;flex-wrap:wrap;flex-direction:row}@media (max-width:768px){.apbct_settings_top_info__btn{display:inline-grid;width:100%;gap:5px}#apbct_settings__advanced_settings_inner,#apbct_settings__after_advanced_settings,.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:100%}.apbct_settings_top_info__sub_btn .apbct_bottom_links--left,.apbct_settings_top_info__sub_btn .apbct_bottom_links--other{margin-left:0;margin-right:0}#apbct_hidden_section_nav ul{display:none;background-color:#dadee3bd;margin:0;padding:10px;border-radius:3px;right:0;width:auto}#apbct_hidden_section_nav{right:0;min-width:167px}.apbct_setting_radio::before{height:6px!important;width:6px!important;margin:4px!important}.apbct_setting_checkbox::before{height:15px!important;width:15px!important;margin:0 -.05rem!important}.apbct_setting_checkbox,.apbct_setting_radio{height:16px!important;width:16px!important}.apbct_hidden_section_nav_mob_btn{display:block;width:32px;height:28px;right:20px;top:20px;position:fixed}.apbct_hidden_section_nav_mob_btn-close{display:block;position:relative;float:right;width:20px;height:22px;top:-5px;right:-5px;background-image:url(images/cancel.svg);background-repeat:no-repeat;background-size:contain;background-position-y:center;text-align:center}.apbct_long_desc{left:-2%!important;max-width:95%;margin-top:10%}.apbct_long_desc__angle{display:none}.ct_rate_block{max-width:240px;margin-right:20px}.apbct_settings__key_line{display:flex;align-items:flex-start;flex-direction:column;width:100%}.apbct_settings__key_line__elements{margin:5px 0}#apbct_setting_apikey,.apbct_setting__key_line__buttons,.apbct_settings__key_line__elements{width:100%}#cleantalk_apikey_wrapper{max-width:100%}#apbct_settings__button_section{position:fixed;right:20px}.apcbt_contact_data_encoder__line{max-width:100%;margin-top:5px}} \ No newline at end of file diff --git a/css/cleantalk-email-decoder.min.css b/css/cleantalk-email-decoder.min.css index b26b046ca..d97ef5ee4 100644 --- a/css/cleantalk-email-decoder.min.css +++ b/css/cleantalk-email-decoder.min.css @@ -1 +1 @@ -.apbct_dog_one,.apbct_dog_three,.apbct_dog_two{animation-duration:1.5s;animation-iteration-count:infinite;animation-name:apbct_dog}.apbct-email-encoder-popup{width:30vw;min-width:400px;font-size:16px}.apbct-email-encoder--popup-header{font-size:16px;color:#333}.apbct-email-encoder-elements_center{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:16px!important;color:#000!important}.top-margin-long{margin-top:5px}.apbct-tooltip{display:none}.apbct-email-encoder{position:relative}.apbct-blur{filter:blur(5px);transition:filter 2s}.apbct-email-encoder.no-blur .apbct-blur{filter:none}.apbct-email-encoder-select-whole-email{-webkit-user-select:all;user-select:all}.apbct-email-encoder-got-it-button{all:unset;margin-top:10px;padding:5px 10px;border-radius:5px;background-color:#333;color:#fff;cursor:pointer;transition:background-color .3s}.apbct-ee-animation-wrapper{display:flex;height:60px;justify-content:center;font-size:16px;align-items:center}.apbct_dog{margin:0 5px;color:transparent;text-shadow:0 0 2px #aaa}.apbct_dog_one{animation-delay:0s}.apbct_dog_two{animation-delay:.5s}.apbct_dog_three{animation-delay:1s}@keyframes apbct_dog{0%,100%,75%{scale:100%;color:transparent;text-shadow:0 0 2px #aaa}25%{scale:200%;color:unset;text-shadow:unset}}.apbct-email-encoder--settings_example_encoded{position:absolute}@media screen and (max-width:782px){.apbct-email-encoder--settings_example_encoded{position:relative;display:block}.apbct-email-encoder-popup{width:20vw;min-width:200px;font-size:16px;top:20%;left:75%}.apbct-email-encoder-elements_center{flex-direction:column!important;text-align:center}} \ No newline at end of file +.apbct_dog_one,.apbct_dog_three,.apbct_dog_two{animation-duration:1.5s;animation-iteration-count:infinite;animation-name:apbct_dog}.apbct-email-encoder,.apbct-email-encoder--settings_example_encoded{position:relative}.apbct-email-encoder-popup{width:30vw;min-width:400px;font-size:16px}.apbct-email-encoder--popup-header{font-size:16px;color:#333}.apbct-email-encoder-elements_center{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:16px!important;color:#000!important}.top-margin-long{margin-top:5px}.apbct-tooltip{display:none}.apbct-blur{filter:blur(5px);transition:filter 2s}.apbct-email-encoder.no-blur .apbct-blur{filter:none}.apbct-email-encoder-select-whole-email{-webkit-user-select:all;user-select:all}.apbct-email-encoder-got-it-button{all:unset;margin-top:10px;padding:5px 10px;border-radius:5px;background-color:#333;color:#fff;cursor:pointer;transition:background-color .3s}.apbct-ee-animation-wrapper{display:flex;height:60px;justify-content:center;font-size:16px;align-items:center}.apbct_dog{margin:0 5px;color:transparent;text-shadow:0 0 2px #aaa}.apbct_dog_one{animation-delay:0s}.apbct_dog_two{animation-delay:.5s}.apbct_dog_three{animation-delay:1s}@keyframes apbct_dog{0%,100%,75%{scale:100%;color:transparent;text-shadow:0 0 2px #aaa}25%{scale:200%;color:unset;text-shadow:unset}}@media screen and (max-width:782px){.apbct-email-encoder--settings_example_encoded{position:relative;display:block}.apbct-email-encoder-popup{width:20vw;min-width:200px;font-size:16px;top:20%;left:75%}.apbct-email-encoder-elements_center{flex-direction:column!important;text-align:center}} \ No newline at end of file diff --git a/css/src/cleantalk-admin-settings-page.css b/css/src/cleantalk-admin-settings-page.css index f48307ccc..c4268f222 100644 --- a/css/src/cleantalk-admin-settings-page.css +++ b/css/src/cleantalk-admin-settings-page.css @@ -69,8 +69,6 @@ i.animate-spin { } .apbct_input_text{min-width: 255px; width: 400px;} -.apbct_settings-field--api_key{font-size: 14pt;} - .apbct_settings-long_description---show:hover{ color: #aaaaaa; cursor: pointer; @@ -163,6 +161,7 @@ a.ct_support_link{ text-align: center; border: 1px dashed #666; } + #ct_translate_plugin .apbct_button_rate{margin-bottom: 10px;} .apbct_long_desc{ @@ -285,17 +284,29 @@ button[value="save_changes"]:disabled { #apbct_hidden_section_nav { position: absolute; top: 0; - right: 20px; + /*right: 20px;*/ + right: 0; + width: 200px; +} +#apbct_hidden_section_nav ul { + /*position: fixed; !!!*/ + z-index: 9999; + width: 100%; + top: 40px; +} +.apbct_settings__position_main_save_button { + text-align: right; + margin-right: 40px; } #apbct_settings__after_advanced_settings{ margin-bottom: 20px; width: 70%; } #apbct_settings__button_section { - position: fixed; + position: static; z-index: 9999; - width: 100%; padding-bottom: 40px; + bottom: 0; } .apbct_highlighted{ @@ -344,6 +355,70 @@ button[value="save_changes"]:disabled { display: none; } +.apbct_settings__footer { + background: #c2c2c2; + position: absolute; + left: 0; + /* right: 0; */ + /* bottom: 0; */ + padding-bottom: 30px; + padding-left: 21px; + /* height: 501px; */ + z-index: -1; +} + + +.apbct_settings_top_info__sub_btn { + display: flex; + flex-wrap: wrap; + gap: 10px; + margin: 15px 0; +} + +.apbct_settings__key_line { + display: flex; + align-items: center; + justify-content: flex-start; + flex-direction: row; +} + +.apbct_settings__key_line__elements { + margin-right: 10px; +} + +.apbct_setting__key_line__buttons { + margin: 0; +} + +.apbct_setting__key_line__get_key_manual_chunk { + margin: 10px 0 10px 0; + border: 1px solid lightgray; + border-radius: 3px; + padding: 10px; + background: #FFF; +} + +.apbct_settings__key_line__service_block{ + margin-left: 10px; +} + +#apbct_settings__public_offer { + margin-top: 10px; + display: flex; + align-items: center; +} + +#cleantalk_apikey_wrapper { + max-width: 65%; +} + +.apcbt_contact_data_encoder__line { + max-width: 70%; + display: flex; + flex-wrap: wrap; + flex-direction: row; +} + @media (max-width: 768px) { .apbct_settings_top_info__btn { display: inline-grid; @@ -372,6 +447,8 @@ button[value="save_changes"]:disabled { margin: 0; padding: 10px; border-radius: 3px; + right: 0; + width: auto; } #apbct_hidden_section_nav { @@ -401,8 +478,9 @@ button[value="save_changes"]:disabled { display: block; width: 32px; height: 28px; - right: -120px; - position: relative; + right: 20px; + top: 20px; + position: fixed; } .apbct_hidden_section_nav_mob_btn-close { @@ -428,11 +506,32 @@ button[value="save_changes"]:disabled { .apbct_long_desc__angle { display: none; } -} + .ct_rate_block{ + max-width: 240px; + margin-right: 20px; + } + .apbct_settings__key_line { + display: flex; + align-items: flex-start; + flex-direction: column; + width: 100%; + } + .apbct_settings__key_line__elements { + margin: 5px 0 5px 0; + } + .apbct_setting__key_line__buttons, #apbct_setting_apikey, .apbct_settings__key_line__elements { + width: 100%; + } + #cleantalk_apikey_wrapper { + max-width: 100%; + } + #apbct_settings__button_section { + position: fixed; + right: 20px; + } -.apbct_settings_top_info__sub_btn { - display: flex; - flex-wrap: wrap; - gap: 10px; - margin: 15px 0; + .apcbt_contact_data_encoder__line { + max-width: 100%; + margin-top: 5px; + } } diff --git a/css/src/cleantalk-email-decoder.css b/css/src/cleantalk-email-decoder.css index 2427c8682..8f8a1c379 100644 --- a/css/src/cleantalk-email-decoder.css +++ b/css/src/cleantalk-email-decoder.css @@ -107,7 +107,7 @@ } .apbct-email-encoder--settings_example_encoded { - position: absolute; + position: relative; } @media screen and (max-width: 782px) { diff --git a/inc/cleantalk-admin.php b/inc/cleantalk-admin.php index 1e9665b6f..646abe220 100644 --- a/inc/cleantalk-admin.php +++ b/inc/cleantalk-admin.php @@ -576,7 +576,7 @@ function apbct_admin__enqueue_scripts($hook) 'ct_subtitle' => $apbct->ip_license ? __('Hosting Anti-Spam', 'cleantalk-spam-protect') : '', 'ip_license' => $apbct->ip_license ? true : false, 'key_changed' => ! empty($apbct->data['key_changed']), - 'key_is_ok' => ! empty($apbct->key_is_ok) + 'key_is_ok' => ! empty($apbct->key_is_ok) && !empty($apbct->settings['apikey']) )); ApbctEnqueue::getInstance()->js('apbct-public--3--cleantalk-modal.js'); diff --git a/inc/cleantalk-integrations-by-hook.php b/inc/cleantalk-integrations-by-hook.php index 4402f0850..6f19f7e15 100755 --- a/inc/cleantalk-integrations-by-hook.php +++ b/inc/cleantalk-integrations-by-hook.php @@ -339,9 +339,10 @@ ), // Integration Contact Form Clean and Simple 'CSCF' => array( - 'hook' => 'cscf-submitform', + 'hook' => array('cscf-submitform', 'cscf_spamfilter'), 'setting' => 'forms__contact_forms_test', 'ajax' => true, + 'ajax_and_post' => true ), 'ThriveLeads' => array( 'hook' => 'tve_leads_ajax_conversion', diff --git a/inc/cleantalk-pluggable.php b/inc/cleantalk-pluggable.php index 08f7cc53c..af19e6c63 100644 --- a/inc/cleantalk-pluggable.php +++ b/inc/cleantalk-pluggable.php @@ -36,7 +36,13 @@ function apbct_wp_get_current_user() } } - return $user ? $user : $current_user; + if (!is_null($current_user) && $current_user instanceof WP_User) { + $current_user_defined = $current_user->ID === 0 ? null : $current_user; + } else { + $current_user_defined = null; + } + + return $user ? $user : $current_user_defined; } function apbct_wp_set_current_user($user = null) diff --git a/inc/cleantalk-public-integrations.php b/inc/cleantalk-public-integrations.php index 92be87b6b..96dff6dd8 100644 --- a/inc/cleantalk-public-integrations.php +++ b/inc/cleantalk-public-integrations.php @@ -1696,6 +1696,42 @@ function apbct_form__learnpress__testSpam() } } +/** + * Test Appointment Booking Calendar form for spam + * + * @return void + */ +function apbct_form__appointment_booking_calendar__testSpam() +{ + global $ct_comment; + + $params = ct_gfa(apply_filters('apbct__filter_post', $_POST)); + + $sender_info = []; + + if ( ! empty($params['emails_array']) ) { + $sender_info['sender_emails_array'] = $params['emails_array']; + } + + $base_call_result = apbct_base_call( + array( + 'sender_email' => isset($params['email']) ? $params['email'] : Post::get('email'), + 'sender_nickname' => isset($params['nickname']) ? $params['nickname'] : Post::get('first_name'), + 'post_info' => array('comment_type' => 'signup_form_wordpress_learnpress'), + 'sender_info' => $sender_info, + ) + ); + + if ( isset($base_call_result['ct_result']) ) { + $ct_result = $base_call_result['ct_result']; + if ( $ct_result->allow == 0 ) { + $ct_comment = $ct_result->comment; + ct_die(null, null); + exit; + } + } +} + /** * Test OptimizePress form for spam * @@ -1951,7 +1987,7 @@ function apbct_form__ninjaForms__collect_fields_new() } if ( (stripos($field_key, 'email') !== false && $field_type === 'email') || - (function_exists('is_email') && is_email($field['value'])) + (function_exists('is_email') && is_string($field['value']) && is_email($field['value'])) ) { /** * On the plugin side we can not decide which of presented emails have to be used for check as sender_email, diff --git a/inc/cleantalk-public.php b/inc/cleantalk-public.php index b41fc600b..f21f90544 100644 --- a/inc/cleantalk-public.php +++ b/inc/cleantalk-public.php @@ -1287,13 +1287,16 @@ function apbct_enqueue_and_localize_public_scripts() // Bot detector if ( $apbct->settings['data__bot_detector_enabled'] && ! apbct_bot_detector_scripts_exclusion()) { - ApbctEnqueue::getInstance()->custom( - 'ct-bot-detector-wrapper', + // Attention! Skip old enqueue way for external script. + wp_enqueue_script( + 'ct_bot_detector', 'https://moderate.cleantalk.org/ct-bot-detector-wrapper.js', - array(), - null, - array(), - null + [], + APBCT_VERSION, + array( + 'in_footer' => $in_footer, + 'strategy' => 'defer' + ) ); } diff --git a/inc/cleantalk-settings.php b/inc/cleantalk-settings.php index 9d24bdfb7..bdd9c7f89 100644 --- a/inc/cleantalk-settings.php +++ b/inc/cleantalk-settings.php @@ -113,11 +113,6 @@ function apbct_settings__set_fields() ? '
' . __(' - status of SpamFireWall database updating process', 'cleantalk-spam-protect') : ''; - $current_user = wp_get_current_user(); - $current_user_email = $current_user->exists() ? $current_user->user_email : 'example@example.com'; - $emailEncoder = EmailEncoder::getInstance(); - $current_user_email = $emailEncoder->ignoreOpenSSLMode()->modifyContent($current_user_email); - $fields = array( 'main' => array( @@ -170,11 +165,6 @@ function apbct_settings__set_fields() 'long_description' => true, 'display' => ! $apbct->white_label, ), - 'data__email_decoder' => array( - 'type' => 'checkbox', - 'title' => __('Encode contact data', 'cleantalk-spam-protect'), - 'description' => EmailEncoder::getEncoderOptionDescription($current_user_email) - ), 'comments__the_real_person' => array( 'type' => 'checkbox', 'title' => __('The Real Person Badge!', 'cleantalk-spam-protect'), @@ -184,6 +174,11 @@ function apbct_settings__set_fields() ), 'long_description' => true, ), + 'data__email_decoder__status' => array( + 'type' => 'custom_html', + 'title' => __('Encode contact data', 'cleantalk-spam-protect'), + 'long_description' => true, + ), ), ), @@ -500,22 +495,22 @@ function apbct_settings__set_fields() 'title' => __("Set cookies", 'cleantalk-spam-protect'), 'description' => __( - 'The "On" option means ordinary cookies in the visitor\'s browser. If you use cache plugins, some user parameters will be transmitted inaccurately and this may lead to incorrect filtering.', + 'The "On" mode means usual cookies in visitor`s browsers. If you use cache plugins, some visitor parameters may be transmitted from the cache and this will lead to inaccurate spam filtering.', 'cleantalk-spam-protect' ) . '
' . __( - 'Alternative mechanism will store data in database and will not set cookies in browser, so the cache solutions will work just fine.', + 'The "Alternative mechanism" mode means that visitor data will be stored entirely in the site database. Database resource usage may vary depending on site traffic.', 'cleantalk-spam-protect' ) . '
' . __( - 'The "Auto" option is designed to automatically detect the presence of caching plugins on the site, but now it does not always work, so we advise you not to use this option. The option is reserved for long-time customers who are fine with filtering.', + 'The "Auto" mode (default setting) uses the "Off" mode and switches to the "Alternative mechanism" in case of server cache detection (e.g. Varnish, Siteground).', 'cleantalk-spam-protect' ) . '
' . __( - 'The "Off" option uses local storage instead of cookies. Caching plugins have no negative effect. We recommend using this option.', + 'The "Off" mode combines partial data storage in the site database, partial data storage in a browser`s localstorage.', 'cleantalk-spam-protect' ), 'long_description' => true, @@ -623,10 +618,38 @@ function apbct_settings__set_fields() 'title' => __('Show email existence alert when filling in the field', 'cleantalk-spam-protect'), 'description' => __('Check email address exist before sending form data', 'cleantalk-spam-protect'), ), + ), + ), + + // Data Processing + 'contact_data_encoding' => array( + 'title' => __('Contact Data Encoding', 'cleantalk-spam-protect'), + 'section' => 'hidden_section', + 'fields' => array( 'data__email_decoder' => array( 'title' => __('Encode contact data', 'cleantalk-spam-protect'), 'description' => EmailEncoder::getEncoderOptionDescription(), - 'childrens' => array('data__email_decoder_buffer', 'data__email_decoder_obfuscation_mode', 'data__email_decoder_obfuscation_custom_text') + 'childrens' => array( + 'data__email_decoder_buffer', + 'data__email_decoder_obfuscation_mode', + 'data__email_decoder_obfuscation_custom_text', + 'data__email_decoder_encode_phone_numbers', + 'data__email_decoder_encode_email_addresses' + ), + 'long_description' => true, + ), + 'data__email_decoder_encode_email_addresses' => array( + 'title' => __('Encode email addresses', 'cleantalk-spam-protect'), + 'description' => EmailEncoder::getEmailsEncodingDescription(), + 'class' => 'apbct_settings-field_wrapper--sub', + 'parent' => 'data__email_decoder', + ), + 'data__email_decoder_encode_phone_numbers' => array( + 'title' => __('Encode phone numbers', 'cleantalk-spam-protect'), + 'description' => EmailEncoder::getPhonesEncodingDescription(), + 'class' => 'apbct_settings-field_wrapper--sub', + 'parent' => 'data__email_decoder', + 'long_description' => true, ), 'data__email_decoder_obfuscation_mode' => array( 'title' => __('Encoder obfuscation mode', 'cleantalk-spam-protect'), @@ -650,9 +673,8 @@ function apbct_settings__set_fields() 'description' => EmailEncoder::getBufferUsageOptionDescription(), 'parent' => 'data__email_decoder', 'class' => 'apbct_settings-field_wrapper--sub', - 'reverse_trigger' => true, ), - ), + ) ), // Exclusions @@ -1423,10 +1445,12 @@ function apbct_settings__display() */ echo ''; + echo '
'; echo ''; echo '
'; + echo '
'; echo ""; @@ -1441,6 +1465,10 @@ function apbct_settings__display() echo Escape::escKsesPreset($out, 'apbct_settings__display__banner_template'); } } + + if ( $apbct->key_is_ok && !empty($apbct->api_key) ) { + require_once(CLEANTALK_PLUGIN_DIR . 'templates/apbct_settings__footer.php'); + } } /** @@ -1818,118 +1846,104 @@ function apbct_settings__field__state() function apbct_settings__field__apikey() { global $apbct; - - echo '
'; - + $template = @file_get_contents(CLEANTALK_PLUGIN_DIR . 'templates/settings/settings_key_wrapper.html'); + + $define_key_is_provided_by_admin = APBCT_WPMS && ! is_main_site() && ( ! $apbct->allow_custom_key || defined('CLEANTALK_ACCESS_KEY')); + $define_show_key_field = ! (apbct_api_key__is_correct($apbct->api_key) && isset($apbct->data["key_changed"]) && $apbct->data["key_changed"]); + $define_show_deobfuscating_href = apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok && (!isset($apbct->data["key_changed"]) || !$apbct->data["key_changed"]); + + $replaces = [ + 'wpms_admin_provided' => '', + 'key_label_display' => 'style="display:none"', + 'key_label_text' => __('Access key is', 'cleantalk-spam-protect'), + 'key_input_type' => 'hidden', + 'key_input_value' => '', + 'key_input_key' => '', + 'key_input_placeholder' => __('Enter an Access key', 'cleantalk-spam-protect'), + 'key_input_hint' => __('Get an Access key by clicking the blue button or copy/paste your key from https://cleantalk.org/my.', 'cleantalk-spam-protect'), + 'account_name_ob' => '', + 'deobfuscating_href_display' => 'style="display:none"', + 'deobfuscating_href_text' => __('Show the Access key', 'cleantalk-spam-protect'), + 'get_key_auto_wrapper_display' => 'style="display:none"', + 'get_key_auto_button_display' => 'style="display:none"', + 'get_key_auto_button_text' => __('GET ACCESS KEY', 'cleantalk-spam-protect'), + 'get_key_auto_preloader_src' => Escape::escUrl(APBCT_URL_PATH . '/inc/images/preloader2.gif'), + 'get_key_auto_success_icon_src' => Escape::escUrl(APBCT_URL_PATH . '/inc/images/yes.png'), + 'get_key_manual_chunk' => '', + 'get_key_manual_chunk_display' => empty($apbct->settings['apikey']) ? '' : 'style="display:none"', + 'save_changes_button_text' => __('Save the Access key', 'cleantalk-spam-protect'), + 'trying_to_set_bad_key_notice' => __('Please, insert a correct access key before saving changes! Key should contain at least 8 symbols.', 'cleantalk-spam-protect'), + 'public_offer_display' => 'style="display:none"', + 'public_offer_link' => '', + 'need_accept_agreement_notice' => __('You should accept the License Agreement', 'cleantalk-spam-protect'), + ]; + + //WPMS KEY CASE // Using the Access key from Main site, or from CLEANTALK_ACCESS_KEY constant - if ( APBCT_WPMS && ! is_main_site() && ( ! $apbct->allow_custom_key || defined('CLEANTALK_ACCESS_KEY')) ) { - _e('

Access key is provided by network administrator

', 'cleantalk-spam-protect'); - + if ( $define_key_is_provided_by_admin ) { + $replaces['wpms_admin_provided'] = '

' . __('Access key is provided by network administrator', 'cleantalk-spam-protect') . '

'; + foreach ($replaces as $key => $value) { + $template = str_replace('%' . strtoupper($key) . '%', TT::toString($value), $template); + } + echo $template; return; } - if ( ! (apbct_api_key__is_correct($apbct->api_key) && isset($apbct->data["key_changed"]) && $apbct->data["key_changed"]) ) { - echo ''; - } - - echo 'data["key_changed"]) ? 'text' : 'hidden') - . '" - name="cleantalk_settings[apikey]" - value="' - . ($apbct->key_is_ok - ? str_repeat('*', strlen($apbct->api_key)) - : Escape::escHtml($apbct->api_key) - ) - . '" - key="' . $apbct->api_key . '" - size="20" - placeholder="' . __('Enter the Access key', 'cleantalk-spam-protect') . '"' - . ' />'; - - // Show account name associated with the Access key - if ( ! empty($apbct->data['account_name_ob']) ) { - echo '
' - . sprintf( - __('Account at cleantalk.org is %s.', 'cleantalk-spam-protect'), - '' . Escape::escHtml($apbct->data['account_name_ob']) . '' - ) - . '
'; - }; - - // Show Access key button - if ( apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok && - (!isset($apbct->data["key_changed"]) || !$apbct->data["key_changed"]) - ) { - echo '' - . __('Show the Access key', 'cleantalk-spam-protect') - . ''; - } + //LABEL AND FIELD + $replaces['key_label_display'] = $define_show_key_field ? '' : 'style="display:none"'; + $replaces['key_input_type'] = $define_show_key_field ? 'text' : 'hidden'; + $replaces['key_input_value'] = $apbct->key_is_ok ? str_repeat('*', strlen($apbct->api_key)) : Escape::escHtml($apbct->api_key); + $replaces['key_input_key'] = $apbct->api_key; + $replaces['deobfuscating_href_display'] = $define_show_deobfuscating_href ? '' : 'style="display:none"'; - if ( ! (apbct_api_key__is_correct($apbct->api_key) && isset($apbct->data["key_changed"]) && $apbct->data["key_changed"]) ) { - // "Auto Get Key" buttons. License agreement - echo '
'; - - echo '

'; - - // Auto get key - if ( ! $apbct->ip_license ) { - echo ''; - echo ''; - echo '
'; - echo '
'; - } + //ACCOUNT NAME + $replaces['account_name_ob'] = sprintf( + __('Account at cleantalk.org is %s.', 'cleantalk-spam-protect'), + '' . Escape::escHtml($apbct->data['account_name_ob']) . '' + ); + //GET KEY AUTO + $replaces['get_key_auto_wrapper_display'] = $define_show_key_field && empty($apbct->api_key) + ? '' + : 'style="display:none"'; + $replaces['get_key_auto_button_display'] = !$apbct->ip_license ? '' : 'style="display:none"'; - $register_link = LinkConstructor::buildCleanTalkLink('get_access_key_link', 'wordpress-anti-spam-plugin'); - // Warnings - printf( - __( - 'Admin e-mail %s %s will be used for registration оr click here to %sGet Access Key Manually%s.', - 'cleantalk-spam-protect' - ), - '' - . ct_get_admin_email() . - '', - apbct_settings__btn_change_account_email_html(), - '', - '' - ); + . '">'; + $replaces['get_key_manual_chunk'] = sprintf( + $link_template, + '' . ct_get_admin_email() . '', + apbct_settings__btn_change_account_email_html(), + $href, + '' + ); - // License agreement - if ( ! $apbct->ip_license ) { - echo '
'; - echo ''; - echo '"; - echo '
'; - } + //PUBLIC OFFER + $replaces['public_offer_display'] = !$apbct->ip_license ? '' : 'style="display:none"'; + $replaces['public_offer_link'] = sprintf( + '' + ); - echo '
'; + //DO REPLACE + foreach ($replaces as $key => $value) { + $template = str_replace('%' . strtoupper($key) . '%', TT::toString($value), $template); } - - echo '
'; + echo $template; } function apbct_field_service_utilization() @@ -2261,6 +2275,9 @@ function apbct_settings__validate($settings) if ( ! isset($settings[$setting]) ) { $settings[$setting] = null; settype($settings[$setting], gettype($value)); + if ($setting === 'data__email_decoder_obfuscation_mode') { + $settings[$setting] = $value; + } } } unset($setting, $value); @@ -2477,8 +2494,18 @@ function apbct_settings__validate($settings) // Banner notice_email_decoder_changed if ( - isset($apbct->settings['data__email_decoder'], $settings['data__email_decoder']) && - ((int)$apbct->settings['data__email_decoder'] !== (int)$settings['data__email_decoder']) + ( + isset($apbct->settings['data__email_decoder'], $settings['data__email_decoder']) && + ((int)$apbct->settings['data__email_decoder'] !== (int)$settings['data__email_decoder']) + ) || + ( + isset($apbct->settings['data__email_decoder_encode_phone_numbers'], $settings['data__email_decoder_encode_phone_numbers']) && + ((int)$apbct->settings['data__email_decoder_encode_phone_numbers'] !== (int)$settings['data__email_decoder_encode_phone_numbers']) + ) || + ( + isset($apbct->settings['data__email_decoder_encode_email_addresses'], $settings['data__email_decoder_encode_email_addresses']) && + ((int)$apbct->settings['data__email_decoder_encode_email_addresses'] !== (int)$settings['data__email_decoder_encode_email_addresses']) + ) ) { $apbct->data['notice_email_decoder_changed'] = 1; } @@ -3090,9 +3117,17 @@ function apbct_settings__get__long_description()

^my-parent-div$

', ), 'data__email_decoder_obfuscation_mode' => array( - 'title' => __('Email Encoder obfuscation modes', 'cleantalk-spam-protect'), + 'title' => __('Contact data encoding: obfuscation modes', 'cleantalk-spam-protect'), 'desc' => EmailEncoder::getObfuscationModesLongDescription(), ), + 'data__email_decoder_encode_phone_numbers' => array( + 'title' => __('Contact data encoding: phone numbers', 'cleantalk-spam-protect'), + 'desc' => EmailEncoder::getPhonesEncodingLongDescription(), + ), + 'data__email_decoder' => array( + 'title' => __('Contact data encoding', 'cleantalk-spam-protect'), + 'desc' => EmailEncoder::getEmailEncoderCommonLongDescription(), + ), ); if (!empty($setting_id) && isset($descriptions[$setting_id])) { @@ -3172,6 +3207,7 @@ function apbct_settings__btn_change_account_email_html() return '( + + + + + +
+ %GET_KEY_MANUAL_CHUNK% +
+ + %PUBLIC_OFFER_LINK% +
+
+ diff --git a/tests/Antispam/EmailEncoderTest.php b/tests/Antispam/TestEmailEncoder.php similarity index 52% rename from tests/Antispam/EmailEncoderTest.php rename to tests/Antispam/TestEmailEncoder.php index ae6b75b14..8275b7f2c 100644 --- a/tests/Antispam/EmailEncoderTest.php +++ b/tests/Antispam/TestEmailEncoder.php @@ -1,19 +1,11 @@ email_encoder->encodeString($this->plain_text); + $encoded_plain = $this->email_encoder->encoder->encodeString($this->plain_text); $this->assertNotEmpty($encoded_plain); $this->assertIsString($encoded_plain); - $decoded_entity = $this->email_encoder->decodeString($encoded_plain); + $decoded_entity = $this->email_encoder->encoder->decodeString($encoded_plain); $this->assertNotEmpty($decoded_entity); $this->assertIsString($decoded_entity); global $apbct; @@ -45,14 +37,14 @@ public function testPlainTextEncodeDecodeSSL() public function testPlainTextEncodeDecodeBase() { - $encoded_plain = $this->email_encoder->ignoreOpenSSLMode()->encodeString($this->plain_text); + $encoded_plain = $this->email_encoder->ignoreOpenSSLMode()->encoder->encodeString($this->plain_text); $this->assertNotEmpty($encoded_plain); $this->assertIsString($encoded_plain); // make sure that b64 fired instead of ssl $decoded_b_string = base64_decode($encoded_plain); $decoded_b_string = str_rot13($decoded_b_string); $this->assertEquals($this->plain_text, $decoded_b_string); - $decoded_entity = $this->email_encoder->decodeString($encoded_plain); + $decoded_entity = $this->email_encoder->encoder->decodeString($encoded_plain); $this->assertNotEmpty($decoded_entity); $this->assertIsString($decoded_entity); global $apbct; @@ -84,20 +76,20 @@ public function testEmailObfuscationModes() $test_email = 'alex@comon.com'; $test_email_obf = 'al\*\*\@\*\*\*on\.com'; $test_email_replace = 'REPLACEBYME'; - $regexp_for_blur = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.\">[\s\S]+apbct-blur[\s\S]+\*?apbct-blur[\s\S]+\*+<\/span>[\s\S]+<\/span>/'; - $regexp_for_obfuscation = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.\">+' . $test_email_obf . '/'; - $regexp_for_replace = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.\">+' . $test_email_replace . '/'; + $regexp_for_blur = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>[\s\S]+apbct-blur[\s\S]+\*?apbct-blur[\s\S]+\*+<\/span>[\s\S]+<\/span>/'; + $regexp_for_obfuscation = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>+' . $test_email_obf . '/'; + $regexp_for_replace = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>.+' . $test_email_replace . '/'; $apbct->settings['data__email_decoder_obfuscation_mode'] = 'blur'; $apbct->saveSettings(); - $result = $this->email_encoder->modifyEmails($test_email); + $result = $this->email_encoder->modifyContent($test_email); $this->assertNotRegExp($regexp_for_obfuscation, $result); $this->assertNotRegExp($regexp_for_replace, $result); $this->assertRegExp($regexp_for_blur, $result); $apbct->settings['data__email_decoder_obfuscation_mode'] = 'obfuscate'; $apbct->saveSettings(); - $result = $this->email_encoder->modifyEmails($test_email); + $result = $this->email_encoder->modifyContent($test_email); $this->assertNotRegExp($regexp_for_replace, $result); $this->assertNotRegExp($regexp_for_blur, $result); $this->assertRegExp($regexp_for_obfuscation, $result); @@ -105,10 +97,78 @@ public function testEmailObfuscationModes() $apbct->settings['data__email_decoder_obfuscation_mode'] = 'replace'; $apbct->settings['data__email_decoder_obfuscation_custom_text'] = $test_email_replace; $apbct->saveSettings(); - $result = $this->email_encoder->modifyEmails($test_email); + $result = $this->email_encoder->modifyContent($test_email); $this->assertNotRegExp($regexp_for_blur, $result); $this->assertNotRegExp($regexp_for_obfuscation, $result); $this->assertRegExp($regexp_for_replace, $result); } + public function testEncodingPhoneNumbers() + { + global $apbct; + + $apbct->settings['data__email_decoder_obfuscation_mode'] = 'blur'; + $apbct->settings['data__email_decoder_encode_phone_numbers'] = 1; + $apbct->saveSettings(); + + $test_stack = array( + '+442071838750', + '+44 20 7123 4567', + '+12025551234', + '+1 (234) 567-8901', + '+49 30 1234567', + '+33 1 23 45 67 89', + '+7 (123) 456-78-90', + '+7 123 456 78 90', + '+71234567890', + ); + + $test_stack_skip_to = array( + '192.168.2.1', + '8.168.2.1', + '81.234.56.78', + '71234567890', + '+7413033', + '+7(413)033', + '+7 (413) 03 3', + ); + + $regexp_for_blur = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>[\s\S]+apbct-blur[\s\S]+\*?\*+<\/span>[\s\S]+/'; + + foreach ($test_stack as $phone) { + $result = $this->email_encoder->modifyContent($phone); + $this->assertNotEmpty($result); + $this->assertStringNotContainsString($phone, $result); + $this->assertRegExp($regexp_for_blur, $result); + } + + foreach ($test_stack_skip_to as $phone) { + $result = $this->email_encoder->modifyContent($phone); + $this->assertNotEmpty($result); + $this->assertEquals($phone, $result); + } + } + + public function testPhoneEncodingSetting() + { + global $apbct; + + $test_tel_origin = 'Lorem ipsum bla bla +17776663322'; + $test_tel_obfuscated = '\+1777\*\*\*\*\*22'; + $regexp_for_obfuscation = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>+' . $test_tel_obfuscated . '/'; + + $apbct->settings['data__email_decoder_obfuscation_mode'] = 'obfuscate'; + $apbct->settings['data__email_decoder_encode_phone_numbers'] = 1; + $apbct->saveSettings(); + + $result = $this->email_encoder->modifyContent($test_tel_origin); + $this->assertRegExp($regexp_for_obfuscation, $result); + + $apbct->settings['data__email_decoder_encode_phone_numbers'] = 0; + $apbct->saveSettings(); + + $result = $this->email_encoder->modifyContent($test_tel_origin); + $this->assertEquals($test_tel_origin, $result); + } + }