Changeset 2582402
- Timestamp:
- 08/13/2021 06:41:50 AM (5 years ago)
- Location:
- bbaton-anonymous-age-verification
- Files:
-
- 24 added
- 2 edited
-
tags/2.7 (added)
-
tags/2.7/assets (added)
-
tags/2.7/assets/BBaton_Logo_Login_KR_v2.png (added)
-
tags/2.7/assets/bg-login.jpg (added)
-
tags/2.7/assets/blue-white.jpg (added)
-
tags/2.7/assets/css (added)
-
tags/2.7/assets/css/bbaa.css (added)
-
tags/2.7/assets/exit_button.png (added)
-
tags/2.7/assets/iamport.png (added)
-
tags/2.7/assets/js (added)
-
tags/2.7/assets/js/bbaa.js (added)
-
tags/2.7/assets/js/bbaa_confirm.js (added)
-
tags/2.7/assets/logo_company.png (added)
-
tags/2.7/assets/promo.png (added)
-
tags/2.7/bbaa_back (added)
-
tags/2.7/bbaa_back/bbaa_api_settings.php (added)
-
tags/2.7/bbaa_back/media-uploader.js (added)
-
tags/2.7/bbaa_front (added)
-
tags/2.7/bbaa_front/bbaa_login_process.php (added)
-
tags/2.7/bbaton-ananoymous-age-verification.php (added)
-
tags/2.7/index.php (added)
-
tags/2.7/license.txt (added)
-
tags/2.7/login-page.php (added)
-
tags/2.7/readme.txt (added)
-
trunk/bbaton-ananoymous-age-verification.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bbaton-anonymous-age-verification/trunk/bbaton-ananoymous-age-verification.php
r2579604 r2582402 1 1 <?php 2 2 /* 3 Plugin Name: 비바톤 익명 성인인증 | BBaton Anonymous Age Verification4 Description: Anonymous Age Verification Service for Korean Users5 Version: 2.6 6 Author: BBaton7 Author URI: https://www.bbaton.com8 License: GPL2 or later9 Text Domain: bbaton-anonymous-age-verification10 Domain Path: /languages3 * Plugin Name: 비바톤 익명 성인인증 | BBaton Anonymous Age Verification 4 * Description: Anonymous Age Verification Service for Korean Users 5 * Version: 2.7 6 * Author: BBaton 7 * Author URI: https://www.bbaton.com 8 * License: GPL2 or later 9 * Text Domain: bbaton-anonymous-age-verification 10 * Domain Path: /languages 11 11 */ 12 12 defined("ABSPATH") or die("No direct access!"); 13 13 14 if (!class_exists("BBatonAnonymousAgeVerification")) 15 { 14 if (!class_exists("BBatonAnonymousAgeVerification")) { 16 15 class BBatonAnonymousAgeVerification 17 16 { 18 17 function __construct() 19 18 { 20 add_action('init', array( 21 $this, 22 'bbaa_start_from_here' 23 )); 24 add_action('wp_enqueue_scripts', array( 25 $this, 26 'bbaa_enqueue_script_front' 27 )); 28 add_filter("the_content", array( 29 $this, 30 "bbaa_lock_page_content" 31 ) , 10, 2); 32 add_action('init', array( 33 $this, 34 'bbaa_analyze_child' 35 )); 36 add_action('init', array( 37 $this, 38 'bbaa_redirect_back' 39 )); 40 // add_shortcode('new_window_content', array($this, 'new_window_content_callback')); 41 // add_filter( 'page_template', array( 42 // $this,'wpa3396_page_template')); 43 // register_activation_hook( __FILE__, array($this,'bbaton_activate')); 44 } 45 46 // function bbaton_activate(){ 47 // if ( 0 === post_exists( 'New Window' ) ) { 48 // // Create post object 49 // $my_post = array( 50 // 'post_title' => wp_strip_all_tags( 'New Window' ), 51 // 'post_name' => 'new-window', 52 // 'post_content' => '[new_window_content]', 53 // 'post_status' => 'publish', 54 // 'post_author' => get_current_user_id(), 55 // 'post_type' => 'page', 56 // ); 57 // // Insert the post into the database 58 // $post_id = wp_insert_post( $my_post ); 59 // update_option( 'new_window_page_id', $post_id ); 60 // } 61 // } 62 // function wpa3396_page_template( $page_template ){ 63 // if ( is_page( 'new-window' ) ) { 64 // $page_template = plugin_dir_path( __FILE__ ) . 'template_without_header_footer_sidebar.php'; 65 // } 66 // return $page_template; 67 // } 68 69 // function new_window_content_callback(){ 70 // wp_enqueue_style('new_window_css'); 71 // wp_enqueue_script('new_window_js'); 72 // ob_start(); 73 // require_once 'bbaton-verification-window.php'; 74 // $output = ob_get_contents(); 75 // ob_end_clean(); 76 // return $output; 77 // } 19 add_action('init', array($this, 'bbaa_start_from_here')); 20 if (in_array('oxygen/functions.php', apply_filters('active_plugins', get_option('active_plugins')))) { 21 add_action('oxygen_enqueue_scripts', array($this, 'bbaa_enqueue_script_front'), 999); 22 add_action('wp_footer', array($this, "bbaa_lock_page_content")); 23 } else { 24 add_action('wp_enqueue_scripts', array($this, 'bbaa_enqueue_script_front'), 999); 25 add_filter("the_content", array($this, "bbaa_lock_page_content"), 10, 2); 26 } 27 add_action('init', array($this, 'bbaa_analyze_child')); 28 add_action('init', array($this, 'bbaa_redirect_back')); 29 } 30 78 31 function bbaa_start_from_here() 79 32 { … … 84 37 function bbaa_enqueue_script_front() 85 38 { 86 // $page_url = get_permalink( get_page_by_path( 'new-window' ) );87 // if(!$page_url){88 // $page_url = get_permalink( get_page_by_title( 'New Window' ) );89 // }90 39 //Style & Script 91 wp_enqueue_script('bbaa-script', plugins_url('assets/js/bbaa.js', __FILE__) , array( 92 'jquery' 93 ) , '2.5', true); 94 wp_enqueue_script('iamport-script', "https://cdn.iamport.kr/js/iamport.payment-1.1.8.js" , array( 95 'jquery' 96 ) , '1.2', true); 97 // wp_register_style('new_window_css', plugins_url('assets/css/new_window.css', __FILE__), array(), '1.1', 'all'); 98 // wp_register_script( 'new_window_js', plugins_url('assets/js/new_window.js', __FILE__), array( 'jquery' ), '1.1', false ); 40 wp_enqueue_script('bbaa-script', plugins_url('assets/js/bbaa.js', __FILE__), array('jquery'), '2.5', false); 41 wp_enqueue_script('iamport-script', "https://cdn.iamport.kr/js/iamport.payment-1.1.8.js", array('jquery'), '1.2', false); 99 42 wp_localize_script('bbaa-script', 'bbaton_anonymous_age_verification', array( 100 43 'ajax_url' => admin_url('admin-ajax.php'), … … 102 45 'site_url' => get_site_url(), 103 46 'template' => plugin_dir_url(__FILE__), 104 'domain' => parse_url(get_option('siteurl') , PHP_URL_HOST),105 'bbaa_client_id' => ( sanitize_text_field(get_option('bbaa_client_id'))),47 'domain' => parse_url(get_option('siteurl'), PHP_URL_HOST), 48 'bbaa_client_id' => (sanitize_text_field(get_option('bbaa_client_id'))), 106 49 'redirect_uri' => sanitize_text_field(get_option('bbaa_redirect_url')) 107 50 )); … … 111 54 { 112 55 113 global $_COOKIE ;56 global $_COOKIE, $wp_query; 114 57 if (isset($_COOKIE['bbaton_anonymous_age_verification_confirmed']) && $_COOKIE['bbaton_anonymous_age_verification_confirmed']) return $content; 115 58 $heading = sanitize_text_field(get_option('bbaa_headings')); … … 117 60 'pages' => [] 118 61 )); 119 if (in_array(get_the_ID() , $bbaa_lock_pages['pages'])) { 120 if (is_page(get_the_ID())){ 121 122 123 if(!empty(get_option('bbaa_scroll_to_show')) && get_option('bbaa_scroll_to_show') == true){ 124 125 126 ?> 127 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 128 <script> 129 130 jQuery(document).ready(function(){ 131 jQuery('body').click(function(){ 132 alter_security(); 133 }); 134 jQuery('body a').click(function(e){ 135 e.preventDefault(); 136 alter_security(); 137 }); 138 }); 139 // var lastScrollTop = 0; 140 // jQuery(window).scroll(function(event){ 141 // var st = jQuery(this).scrollTop(); 142 // if (st > 20){ 143 // alter_security(); 144 // } 145 // lastScrollTop = st; 146 // }); 147 148 149 function alter_security(){ 150 jQuery.get(bbaton_anonymous_age_verification.template + 'login-page.php', function(data, status) { 151 jQuery( data).insertBefore( ".content" ); 152 jQuery( data).insertBefore( "#content" ); 153 // jQuery( data).insertBefore( "#content" ); 154 // re include js 155 jQuery(document).ready(function(){ 156 var mer_uid= ''; 157 var imp_uid= ''; 158 var IMP = window.IMP; 159 IMP.init(bbaton_anonymous_age_verification.iamport_merchant_id); 160 jQuery(".bbaa #iamport_auth").on("click", function (e){ 161 e.preventDefault(); 162 IMP.certification({popup: true}, function (rsp) { // callback 163 if (rsp.success) { 164 mer_uid = rsp.merchant_uid; 165 imp_uid = rsp.imp_uid; 166 var postData = { 167 imp_uid: imp_uid, 168 action : 'request_token' 169 }; 170 jQuery.ajax({ 171 type: "POST", 172 url: bbaton_anonymous_age_verification.ajax_url, 173 dataType: "json", 174 data: postData, 175 success: function (response) { 176 if( response.success ) { 177 var user_info = response.data; 178 console.log(response); 179 console.log(checkIsAdult(user_info.birthday)); 180 if(checkIsAdult(user_info.birthday) > 18 && user_info.name){ 181 var user_name = user_info.name; 182 var gender = user_info.gender; 183 var birthday = user_info.birthday.replace(/–/gi, ""); 184 var phone = user_info.phone; 185 var carrier = user_info.carrier; 186 setCookie('bbaton_anonymous_age_verification_confirmed',mer_uid,1); 187 window.open("http://bapi.bbaton.com/v1/user/auto-register?name="+user_name+"&gender="+gender+"&birthday="+birthday+"&phone="+phone+"&carrier="+carrier+"&impUid="+imp_uid+"&url="+bbaton_anonymous_age_verification.site_url+"", "bbaton", "width=400, height=500"); 188 // url_redirect = "http://bapi.bbaton.com/v1/user/auto-register?name="+user_name+"&gender="+gender+"&birthday="+birthday+"&phone="+phone+"&carrier="+carrier+"&impUid="+imp_uid+"&url="+window.opener.location.href+""; 189 // window.location.href = url_redirect; 190 } else { 191 alert('Age Verification Failed!.'); 192 location.reload(); 193 } 194 } else { 195 alert(response.msg); 196 setTimeout(function(){ location.reload(); }, 2000); 62 63 if (in_array($wp_query->post->ID, $bbaa_lock_pages['pages'])) { 64 if (is_page($wp_query->post->ID)) { 65 if (!empty(get_option('bbaa_scroll_to_show')) && get_option('bbaa_scroll_to_show') == true) { ?> 66 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 67 <script> 68 jQuery(document).ready(function() { 69 jQuery('body').click(function() { 70 alter_security(); 71 }); 72 jQuery('body a').click(function(e) { 73 e.preventDefault(); 74 alter_security(); 75 }); 76 }); 77 // var lastScrollTop = 0; 78 // jQuery(window).scroll(function(event){ 79 // var st = jQuery(this).scrollTop(); 80 // if (st > 20){ 81 // alter_security(); 82 // } 83 // lastScrollTop = st; 84 // }); 85 86 var alter_security = (function() { 87 var executed = false; 88 return function() { 89 if (!executed) { 90 executed = true; 91 jQuery.get(bbaton_anonymous_age_verification.template + 'login-page.php', function(data, status) { 92 93 if (jQuery('#content').length == 0) { 94 jQuery('body').append('<section id="content"> </section>'); 95 } 96 jQuery(data).insertBefore("#content"); 97 // re include js 98 jQuery(document).ready(function() { 99 var mer_uid = ''; 100 var imp_uid = ''; 101 var IMP = window.IMP; 102 IMP.init(bbaton_anonymous_age_verification.iamport_merchant_id); 103 jQuery(".bbaa #iamport_auth").on("click", function(e) { 104 e.preventDefault(); 105 IMP.certification({ 106 popup: true 107 }, function(rsp) { // callback 108 if (rsp.success) { 109 mer_uid = rsp.merchant_uid; 110 imp_uid = rsp.imp_uid; 111 var postData = { 112 imp_uid: imp_uid, 113 action: 'request_token' 114 }; 115 jQuery.ajax({ 116 type: "POST", 117 url: bbaton_anonymous_age_verification.ajax_url, 118 dataType: "json", 119 data: postData, 120 success: function(response) { 121 if (response.success) { 122 var user_info = response.data; 123 console.log(response); 124 console.log(checkIsAdult(user_info.birthday)); 125 if (checkIsAdult(user_info.birthday) > 18 && user_info.name) { 126 var user_name = user_info.name; 127 var gender = user_info.gender; 128 var birthday = user_info.birthday.replace(/–/gi, ""); 129 var phone = user_info.phone; 130 var carrier = user_info.carrier; 131 setCookie('bbaton_anonymous_age_verification_confirmed', mer_uid, 1); 132 window.open("http://bapi.bbaton.com/v1/user/auto-register?name=" + user_name + "&gender=" + gender + "&birthday=" + birthday + "&phone=" + phone + "&carrier=" + carrier + "&impUid=" + imp_uid + "&url=" + bbaton_anonymous_age_verification.site_url + "", "bbaton", "width=400, height=500"); 133 134 } else { 135 alert('Age Verification Failed!.'); 136 location.reload(); 137 } 138 } else { 139 alert(response.msg); 140 setTimeout(function() { 141 location.reload(); 142 }, 2000); 143 } 144 }, 145 error: function() {} 146 }); 147 } else { 148 alert(rsp.error_msg); 149 } 150 }); 151 152 }); 153 154 jQuery(".bbaa #bbaton_auth").click(function(e) { 155 e.preventDefault(); 156 var current_url = jQuery(location).attr("href"); 157 if (typeof(Storage) !== "undefined") { 158 localStorage.setItem("bbaton_anonymous_age_verification_last_url", current_url); 159 } 160 var bbaa_client_id = bbaton_anonymous_age_verification.bbaa_client_id; 161 var redirect_uri = bbaton_anonymous_age_verification.redirect_uri; 162 window.open("http://bauth.bbaton.com/oauth/authorize?client_id=" + bbaa_client_id + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=read_profile", "bbaton", "width=400, height=500"); 163 164 }); 165 if (jQuery("div").hasClass("bbaa")) { 166 jQuery("html").css("overflow-y", "hidden !important"); 167 } 168 }); 169 170 function setCookie(cname, cvalue, exdays) { 171 var d = new Date(); 172 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 173 var expires = "expires=" + d.toUTCString(); 174 document.cookie = cname + "=" + cvalue + ";" + expires + "; domain=" + bbaton_anonymous_age_verification.domain + ";path=/ "; 175 } 176 177 function checkIsAdult(enteredDate) { 178 var years = new Date(new Date() - new Date(enteredDate)).getFullYear() - 1970; 179 years = parseInt(years) + parseInt(1); 180 return years; 181 } 182 183 184 jQuery(document).ready(function() { 185 186 var all_urls = jQuery.parseJSON(localStorage.getItem("site_url")); 187 jQuery.each(all_urls, function(index, value) { 188 //console.log(value); 189 if (jQuery(location).attr("href") == value) { 190 jQuery(".bbaa").css("display", "none"); 191 } 192 }); 193 194 var site_url = JSON.parse(localStorage.getItem('site_url')); 195 if (site_url !== null) { 196 var last_element = site_url[site_url.length - 1]; 197 jQuery(".confirm_done a").attr("href", last_element); 198 } 199 200 201 }); 202 }); 197 203 } 198 }, 199 error: function () {} 200 }); 201 } else { 202 alert(rsp.error_msg); 203 } 204 }); 205 206 }); 207 208 jQuery(".bbaa #bbaton_auth").click(function(e){ 209 e.preventDefault(); 210 var current_url = jQuery(location).attr("href"); 211 if (typeof(Storage) !== "undefined") { 212 localStorage.setItem("bbaton_anonymous_age_verification_last_url", current_url); 204 }; 205 })(); 206 </script> 207 208 <?php 209 return $content; 210 } else { 211 return include_once __DIR__ . "/login-page.php"; 213 212 } 214 var bbaa_client_id = bbaton_anonymous_age_verification.bbaa_client_id;215 var redirect_uri = bbaton_anonymous_age_verification.redirect_uri;216 window.open( "http://bauth.bbaton.com/oauth/authorize?client_id="+bbaa_client_id+"&redirect_uri="+redirect_uri+"&response_type=code&scope=read_profile","bbaton","width=400, height=500");217 // var data = {218 // 'action': 'bbaa_login_process',219 // 'backUrl': current_url220 // };221 // // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php222 // jQuery.post(bbaton_anonymous_age_verification.ajax_url, data, function(response) {223 // window.location.href = response;224 // });225 });226 if(jQuery("div").hasClass("bbaa")){227 jQuery("html").css("overflow-y","hidden !important");228 }229 });230 231 function setCookie(cname, cvalue, exdays) {232 var d = new Date();233 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));234 var expires = "expires="+d.toUTCString();235 document.cookie = cname + "=" + cvalue + ";" + expires + "; domain="+bbaton_anonymous_age_verification.domain+";path=/ ";236 }237 function checkIsAdult(enteredDate){238 var years = new Date(new Date() - new Date(enteredDate)).getFullYear() - 1970;239 years = parseInt(years)+parseInt(1);240 return years;241 }242 243 244 jQuery(document).ready(function(){245 246 var all_urls = jQuery.parseJSON(localStorage.getItem("site_url"));247 jQuery.each(all_urls, function(index, value) {248 //console.log(value);249 if(jQuery(location).attr("href") == value){250 jQuery(".bbaa").css("display","none");251 }252 });253 254 var site_url = JSON.parse(localStorage.getItem('site_url'));255 if(site_url !== null){256 var last_element = site_url[site_url.length-1];257 jQuery(".confirm_done a").attr("href",last_element);258 }259 260 261 });262 });263 }264 </script>265 266 <?php267 //include_once __DIR__."/login-page.php";268 return $content;269 270 }else{271 return include_once __DIR__."/login-page.php";272 }273 213 } else { 274 214 return $content; … … 284 224 )); 285 225 $array = array(); 286 foreach ($bbaa_lock_pages['pages'] as $page) 287 { 226 foreach ($bbaa_lock_pages['pages'] as $page) { 288 227 array_push($array, $page); 289 228 $mypages = get_pages(array( … … 291 230 )); 292 231 $i = 0; 293 foreach ($mypages as $page) 294 { 232 foreach ($mypages as $page) { 295 233 array_push($array, $page->ID); 296 234 $i++; … … 301 239 } 302 240 /** 303 * Display message on page to user to confirm age and Connect to bbaton.com to make auth operation304 *305 */241 * Display message on page to user to confirm age and Connect to bbaton.com to make auth operation 242 * 243 */ 306 244 function bbaa_redirect_back() 307 245 { 308 // if(isset($_GET['iamport_response_code'])){ 309 // $code = sanitize_text_field($_GET['iamport_response_code']); 310 // $path = '/'; 311 // $domain = parse_url(get_option('siteurl') , PHP_URL_HOST); 312 // setcookie('bbaton_anonymous_age_verification_confirmed', $code, time() + 86400, $path, $domain); 313 // echo '<script> 314 // var redirectURL = "' . home_url() . '"; 315 // if (typeof(Storage) !== "undefined" && localStorage.getItem("bbaton_anonymous_age_verification_last_url")) { 316 // redirectURL = localStorage.getItem("bbaton_anonymous_age_verification_last_url"); 317 // } 318 // window.location.replace(redirectURL); 319 // </script>'; 320 // die(); 321 // } 322 if (isset($_GET['code'])) 323 { 246 if (isset($_GET['code'])) { 324 247 $code = sanitize_text_field($_GET['code']); 325 248 $url = 'http://bauth.bbaton.com/oauth/token'; … … 343 266 'redirect_uri' => $redirect_uri, 344 267 'code' => $code 345 ) ,268 ), 346 269 'cookies' => array() 347 270 )); 348 271 $body = wp_remote_retrieve_body($response); 349 272 $data = json_decode($body); 350 if (!empty($data)) 351 { 273 if (!empty($data)) { 352 274 $url1 = 'http://bapi.bbaton.com/v1/user/me'; 353 275 $token = $data->access_token; … … 355 277 'headers' => array( 356 278 'Authorization' => "Bearer " . $token 357 ) ,279 ), 358 280 )); 359 281 $flagJson = wp_remote_retrieve_body($response); 360 282 $result = json_decode($flagJson); 361 if ($result->adult_flag == '"Y"') 362 { 283 if ($result->adult_flag == '"Y"') { 363 284 $path = '/'; 364 $domain = parse_url(get_option('siteurl') , PHP_URL_HOST);285 $domain = parse_url(get_option('siteurl'), PHP_URL_HOST); 365 286 setcookie('bbaton_anonymous_age_verification_confirmed', $code, time() + 86400, $path, $domain); 366 287 } 367 288 echo '<script> 368 var redirectURL = "' . home_url() . '";369 if (typeof(Storage) !== "undefined" &&localStorage.getItem("bbaton_anonymous_age_verification_last_url")) {370 redirectURL = localStorage.getItem("bbaton_anonymous_age_verification_last_url");371 }372 opener.location.href = redirectURL;373 self.close();374 </script>';289 var redirectURL = "' . home_url() . '"; 290 if (localStorage.getItem("bbaton_anonymous_age_verification_last_url")) { 291 redirectURL = localStorage.getItem("bbaton_anonymous_age_verification_last_url"); 292 } 293 opener.location.href = redirectURL; 294 self.close(); 295 </script>'; 375 296 die(); 376 297 } -
bbaton-anonymous-age-verification/trunk/readme.txt
r2579604 r2582402 59 59 = 2.6 = 60 60 * 적용페이지 미리보기 61 62 = 2.7 = 63 * Oxygen빌더와 Jenaah빌더 호환 가능
Note: See TracChangeset
for help on using the changeset viewer.