Changeset 2579604
- Timestamp:
- 08/07/2021 04:37:09 AM (5 years ago)
- Location:
- bbaton-anonymous-age-verification
- Files:
-
- 24 added
- 4 edited
-
tags/2.6 (added)
-
tags/2.6/assets (added)
-
tags/2.6/assets/BBaton_Logo_Login_KR_v2.png (added)
-
tags/2.6/assets/bg-login.jpg (added)
-
tags/2.6/assets/blue-white.jpg (added)
-
tags/2.6/assets/css (added)
-
tags/2.6/assets/css/bbaa.css (added)
-
tags/2.6/assets/exit_button.png (added)
-
tags/2.6/assets/iamport.png (added)
-
tags/2.6/assets/js (added)
-
tags/2.6/assets/js/bbaa.js (added)
-
tags/2.6/assets/js/bbaa_confirm.js (added)
-
tags/2.6/assets/logo_company.png (added)
-
tags/2.6/assets/promo.png (added)
-
tags/2.6/bbaa_back (added)
-
tags/2.6/bbaa_back/bbaa_api_settings.php (added)
-
tags/2.6/bbaa_back/media-uploader.js (added)
-
tags/2.6/bbaa_front (added)
-
tags/2.6/bbaa_front/bbaa_login_process.php (added)
-
tags/2.6/bbaton-ananoymous-age-verification.php (added)
-
tags/2.6/index.php (added)
-
tags/2.6/license.txt (added)
-
tags/2.6/login-page.php (added)
-
tags/2.6/readme.txt (added)
-
trunk/bbaa_back/bbaa_api_settings.php (modified) (2 diffs)
-
trunk/bbaton-ananoymous-age-verification.php (modified) (3 diffs)
-
trunk/login-page.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bbaton-anonymous-age-verification/trunk/bbaa_back/bbaa_api_settings.php
r2483497 r2579604 4 4 if (!function_exists('bbaa_plugin_create_menu')) 5 5 { 6 function bbaa_plugin_create_menu()7 {6 function bbaa_plugin_create_menu() 7 { 8 8 9 //create new top-level menu10 add_menu_page('BBaton Settings', 'BBaton Settings', 'manage_options', 'bbaa_settings', 'bbaa_plugin_settings_page', 'dashicons-yes-alt', 25);9 //create new top-level menu 10 add_menu_page('BBaton Settings', 'BBaton Settings', 'manage_options', 'bbaa_settings', 'bbaa_plugin_settings_page', 'dashicons-yes-alt', 25); 11 11 12 //call register settings function 13 add_action('admin_init', 'register_my_bbaa_plugin_settings'); 14 } 12 //call register settings function 13 add_action('admin_init', 'register_my_bbaa_plugin_settings'); 14 add_option('bbaa_scroll_to_show','true'); 15 } 15 16 } 16 17 function media_uploader_enqueue() { 17 wp_enqueue_media();18 wp_register_script('media-uploader', plugins_url('media-uploader.js' , __FILE__ ), array('jquery'));19 wp_enqueue_script('media-uploader');18 wp_enqueue_media(); 19 wp_register_script('media-uploader', plugins_url('media-uploader.js' , __FILE__ ), array('jquery')); 20 wp_enqueue_script('media-uploader'); 20 21 } 21 22 add_action('admin_enqueue_scripts', 'media_uploader_enqueue'); … … 23 24 if (!function_exists('register_my_bbaa_plugin_settings')) 24 25 { 25 function register_my_bbaa_plugin_settings() 26 { 27 //register our settings 28 register_setting('bbaa-plugin-settings-group', 'bbaa_client_id'); 29 register_setting('bbaa-plugin-settings-group', 'background_image'); 30 register_setting('bbaa-plugin-settings-group', 'bbaa_client_secret'); 31 register_setting('bbaa-plugin-settings-group', 'bbaa_redirect_url'); 32 register_setting('bbaa-plugin-settings-group', 'bbaa_lock_pages'); 33 register_setting('bbaa-plugin-settings-group', 'bbaa_exit_url'); 34 } 26 function register_my_bbaa_plugin_settings() 27 { 28 //register our settings 29 register_setting('bbaa-plugin-settings-group', 'bbaa_client_id'); 30 register_setting('bbaa-plugin-settings-group', 'background_image'); 31 register_setting('bbaa-plugin-settings-group', 'bbaa_client_secret'); 32 register_setting('bbaa-plugin-settings-group', 'bbaa_redirect_url'); 33 register_setting('bbaa-plugin-settings-group', 'bbaa_lock_pages'); 34 register_setting('bbaa-plugin-settings-group', 'bbaa_exit_url'); 35 register_setting('bbaa-plugin-settings-group', 'bbaa_scroll_to_show'); 36 } 35 37 } 36 38 37 39 if (!function_exists('bbaa_plugin_settings_page')) 38 40 { 39 function bbaa_plugin_settings_page()40 {41 function bbaa_plugin_settings_page() 42 { 41 43 ?> 42 44 <script type="text/javascript"> 43 44 jQuery(document).ready(function(){45 46 jQuery("#all_pages_parent option").each(function(){47 if(jQuery(this).attr('status') == 0){48 jQuery(this).show();49 }else{50 jQuery(this).hide();51 }52 });53 45 54 //console.log(status); 55 56 }); 46 jQuery(document).ready(function(){ 47 48 jQuery("#all_pages_parent option").each(function(){ 49 if(jQuery(this).attr('status') == 0){ 50 jQuery(this).show(); 51 }else{ 52 jQuery(this).hide(); 53 } 54 }); 55 56 //console.log(status); 57 58 }); 57 59 58 60 </script> 59 61 <div class="wrap" style="background: #fff;padding: 10px 15px;box-shadow: 1px 1px 3px #ddd, -1px -1px 3px #ddd;"> 60 <h1><?php echo __('BBaton Anonymous Age Verification'); ?> </h1><hr>61 <p>비바톤을 웹사이트에 적용하기 위해서는 클라이언트 가입을 통한 웹사이트 연결이 필요합니다. www.bbaton.com 에서 연결을 신청해주세요.</p>62 <?php settings_errors(); ?>62 <h1><?php echo __('BBaton Anonymous Age Verification'); ?> </h1><hr> 63 <p>비바톤을 웹사이트에 적용하기 위해서는 클라이언트 가입을 통한 웹사이트 연결이 필요합니다. www.bbaton.com 에서 연결을 신청해주세요.</p> 64 <?php settings_errors(); ?> 63 65 64 <form method="post" action="options.php"> 65 <?php settings_fields('bbaa-plugin-settings-group'); ?> 66 <?php do_settings_sections('bbaa-plugin-settings-group'); ?> 66 <form method="post" action="options.php"> 67 <?php 67 68 68 <?php 69 $bbaa_lock_pages = get_option('bbaa_lock_pages', array('pages' => [])); 70 $bbaa_headings = sanitize_text_field(get_option('bbaa_headings')); 71 ?> 69 settings_fields('bbaa-plugin-settings-group'); ?> 70 <?php do_settings_sections('bbaa-plugin-settings-group'); ?> 72 71 73 <table class="form-table"> 74 <tr valign="top"> 75 <th scope="row"><?php echo __('비바톤 Client ID'); ?></th> 76 <td><input type="text" name="bbaa_client_id" value="<?php echo sanitize_text_field(get_option('bbaa_client_id')); ?>" style="width:70%;"/></td> 77 </tr> 78 79 <tr valign="top"> 80 <th scope="row"><?php echo __('비바톤 Secret key'); ?></th> 81 <td><input type="text" name="bbaa_client_secret" value="<?php echo sanitize_text_field(get_option('bbaa_client_secret')); ?>" style="width:70%;"/></td> 82 </tr> 72 <?php 73 $bbaa_lock_pages = get_option('bbaa_lock_pages', array('pages' => [])); 74 $bbaa_headings = sanitize_text_field(get_option('bbaa_headings')); 75 ?> 83 76 84 <tr valign="top"> 85 <th scope="row"><?php echo __('비바톤 redirect url'); ?></th> 86 <td><input type="text" name="bbaa_redirect_url" value="<?php echo sanitize_text_field(get_option('bbaa_redirect_url')); ?>" style="width:70%;"/></td> 87 </tr> 88 89 90 <tr valign="top"> 91 <th scope="row"><?php echo __('19세미만 랜딩페이지 (Not adult lending page url)'); ?></th> 92 <td> 93 <?php 94 $pages = get_pages(); 95 ?> 96 <select name="bbaa_exit_url" id="" > 97 <?php 98 foreach ($pages as $page_data) { 99 $link = get_page_link($page_data->ID); 100 $is_selected = sanitize_text_field(get_option('bbaa_exit_url')) == $link ? "selected" : null; 101 ?> 77 <table class="form-table"> 78 <tr valign="top"> 79 <th scope="row"><?php echo __('비바톤 Client ID'); ?></th> 80 <td><input type="text" name="bbaa_client_id" value="<?php echo sanitize_text_field(get_option('bbaa_client_id')); ?>" style="width:70%;"/></td> 81 </tr> 102 82 103 <option value="<?php echo $link; ?>" <?php echo $is_selected; ?>><?php echo $page_data->post_title;?></option> 83 <tr valign="top"> 84 <th scope="row"><?php echo __('비바톤 Secret key'); ?></th> 85 <td><input type="text" name="bbaa_client_secret" value="<?php echo sanitize_text_field(get_option('bbaa_client_secret')); ?>" style="width:70%;"/></td> 86 </tr> 104 87 105 <?php } ?> 106 </select> 107 108 </tr> 109 110 <tr valign="top"> 111 <th scope="row"><?php echo __('성인인증 적용페이지 (Select page to be applied)'); ?></th> 112 <td> 113 <select name="bbaa_lock_pages[pages][]" multiple="multiple" style="width:100%; max-width: 70%;" id="all_pages_parent"> 114 <option value="9999999999999999999" style="text-transform:capitalize;" status="0" 115 116 <?php $none = $bbaa_lock_pages['pages'][0]; 117 118 if ($none == "9999999999999999999") 119 { 120 echo "selected='selected' "; 121 } ?> >None</option> 88 <tr valign="top"> 89 <th scope="row"><?php echo __('비바톤 redirect url'); ?></th> 90 <td><input type="text" name="bbaa_redirect_url" value="<?php echo sanitize_text_field(get_option('bbaa_redirect_url')); ?>" style="width:70%;"/></td> 91 </tr> 122 92 123 93 124 <?php 94 <tr valign="top"> 95 <th scope="row"><?php echo __('19세미만 랜딩페이지 (Not adult lending page url)'); ?></th> 96 <td> 97 <?php 98 $pages = get_pages(); 99 ?> 100 <select name="bbaa_exit_url" id="" > 101 <?php 102 foreach ($pages as $page_data) { 103 $link = get_page_link($page_data->ID); 104 $is_selected = sanitize_text_field(get_option('bbaa_exit_url')) == $link ? "selected" : null; 105 ?> 125 106 126 $pages = get_pages(); 107 <option value="<?php echo $link; ?>" <?php echo $is_selected; ?>><?php echo $page_data->post_title;?></option> 127 108 128 $i = 0; 109 <?php } ?> 110 </select> 129 111 130 foreach ($pages as $page) 131 { 132 if (in_array($page->ID, $bbaa_lock_pages['pages'])) 133 { 134 $option = '<option value="' . $page->ID . '" style="text-transform:capitalize;" selected="selected" status="' . $page->post_parent . '">'; 135 $option .= $page->post_title; 136 $option .= '</option>'; 137 } 138 else 139 { 140 $option = '<option value="' . $page->ID . '" style="text-transform:capitalize;" status="' . $page->post_parent . '">'; 141 $option .= $page->post_title; 142 $option .= '</option>'; 112 </tr> 143 113 144 } 145 echo $option; 146 $i++; 147 } 148 ?> 149 </select> 150 </td> 151 </tr> 114 <tr valign="top"> 115 <th scope="row"><?php echo __('성인인증 적용페이지 (Select page to be applied)'); ?></th> 116 <td> 117 <select name="bbaa_lock_pages[pages][]" multiple="multiple" style="width:100%; max-width: 70%;" id="all_pages_parent"> 118 <option value="9999999999999999999" style="text-transform:capitalize;" status="0" 152 119 153 <tr valign="top"> 154 <th scope="row"><?php echo __('성인인증 적용페이지 표시될 로고 (500x500 사용권장, Client Logo)'); ?></th> 155 <td><input id="background_image" type="text" name="background_image" value="<?php echo get_option('background_image'); ?>" /> 156 <input id="upload_image_button" type="button" class="button-primary" value="Insert Logo" /> 157 </td> 158 </tr> 120 <?php $none = $bbaa_lock_pages['pages'][0]; 159 121 160 122 if ($none == "9999999999999999999") 123 { 124 echo "selected='selected' "; 125 } ?> >None</option> 161 126 162 </table>163 127 164 <?php submit_button(); ?> 128 <?php 165 129 166 </form> 130 $pages = get_pages(); 131 132 $i = 0; 133 134 foreach ($pages as $page) 135 { 136 if (in_array($page->ID, $bbaa_lock_pages['pages'])) 137 { 138 $option = '<option value="' . $page->ID . '" style="text-transform:capitalize;" selected="selected" status="' . $page->post_parent . '">'; 139 $option .= $page->post_title; 140 $option .= '</option>'; 141 } 142 else 143 { 144 $option = '<option value="' . $page->ID . '" style="text-transform:capitalize;" status="' . $page->post_parent . '">'; 145 $option .= $page->post_title; 146 $option .= '</option>'; 147 148 } 149 echo $option; 150 $i++; 151 } 152 ?> 153 </select> 154 </td> 155 </tr> 156 157 <tr valign="top"> 158 <th scope="row"><?php echo __('성인인증 적용페이지 표시될 로고 (500x500 사용권장, Client Logo)'); ?></th> 159 <td><input id="background_image" type="text" name="background_image" value="<?php echo get_option('background_image'); ?>" /> 160 <input id="upload_image_button" type="button" class="button-primary" value="Insert Logo" /> 161 </td> 162 </tr> 163 <tr valign="top"> 164 <th scope="row"><?php echo __('적용페이지 미리보기 Show Preview', 'Client Logo'); ?></th> 165 <td><input id="bbaa_scroll_to_show" type="checkbox" name="bbaa_scroll_to_show" <?php if(get_option('bbaa_scroll_to_show') == true){ echo "checked='checked'";}?> value="<?php 166 if(!empty(get_option('bbaa_scroll_to_show')) && get_option('bbaa_scroll_to_show') == true){echo get_option('bbaa_scroll_to_show');} ?>" /> 167 </td> 168 </tr> 169 170 171 </table> 172 173 <?php submit_button(); ?> 174 <script> 175 176 jQuery(document).ready(function(){ 177 jQuery('#bbaa_scroll_to_show').click(function(){ 178 if (jQuery(this).prop("checked") === true) { 179 jQuery(this).val("true"); 180 }else{ 181 jQuery(this).val('false'); 182 } 183 }) 184 }); 185 186 </script> 187 </form> 167 188 </div> 168 189 <?php 169 }190 } 170 191 } ?> -
bbaton-anonymous-age-verification/trunk/bbaton-ananoymous-age-verification.php
r2483497 r2579604 3 3 Plugin Name: 비바톤 익명 성인인증 | BBaton Anonymous Age Verification 4 4 Description: Anonymous Age Verification Service for Korean Users 5 Version: 2. 55 Version: 2.6 6 6 Author: BBaton 7 7 Author URI: https://www.bbaton.com … … 14 14 if (!class_exists("BBatonAnonymousAgeVerification")) 15 15 { 16 class BBatonAnonymousAgeVerification 17 { 18 function __construct() 19 { 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 // } 78 function bbaa_start_from_here() 79 { 80 require_once plugin_dir_path(__FILE__) . 'bbaa_back/bbaa_api_settings.php'; 81 require_once plugin_dir_path(__FILE__) . 'bbaa_front/bbaa_login_process.php'; 82 } 83 // Enqueue Style and Scripts 84 function bbaa_enqueue_script_front() 85 { 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 //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 ); 99 wp_localize_script('bbaa-script', 'bbaton_anonymous_age_verification', array( 100 'ajax_url' => admin_url('admin-ajax.php'), 101 'iamport_merchant_id' => 'imp34765018', 102 'site_url' => get_site_url(), 103 'domain' => parse_url(get_option('siteurl') , PHP_URL_HOST), 104 'bbaa_client_id' =>( sanitize_text_field(get_option('bbaa_client_id')) ), 105 'redirect_uri' => sanitize_text_field(get_option('bbaa_redirect_url')) 106 )); 107 } 108 // Lock Page 109 function bbaa_lock_page_content($content) 110 { 111 global $_COOKIE; 112 if (isset($_COOKIE['bbaton_anonymous_age_verification_confirmed']) && $_COOKIE['bbaton_anonymous_age_verification_confirmed']) return $content; 113 $heading = sanitize_text_field(get_option('bbaa_headings')); 114 $bbaa_lock_pages = get_option('bbaa_lock_pages', array( 115 'pages' => [] 116 )); 117 if (in_array(get_the_ID() , $bbaa_lock_pages['pages'])) { 118 if (is_page(get_the_ID())){ 119 return include_once __DIR__."/login-page.php"; 120 } else { 121 return $content; 122 } 123 } else { 124 return $content; 125 } 126 } 127 function bbaa_analyze_child() 128 { 129 $bbaa_lock_pages = get_option('bbaa_lock_pages', array( 130 'pages' => [] 131 )); 132 $array = array(); 133 foreach ($bbaa_lock_pages['pages'] as $page) 134 { 135 array_push($array, $page); 136 $mypages = get_pages(array( 137 'child_of' => $page 138 )); 139 $i = 0; 140 foreach ($mypages as $page) 141 { 142 array_push($array, $page->ID); 143 $i++; 144 } 145 } 146 $bbaa_lock_pages['pages'] = $array; 147 update_option("bbaa_lock_pages", $bbaa_lock_pages); 148 } 149 /** 16 class BBatonAnonymousAgeVerification 17 { 18 function __construct() 19 { 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 // } 78 function bbaa_start_from_here() 79 { 80 require_once plugin_dir_path(__FILE__) . 'bbaa_back/bbaa_api_settings.php'; 81 require_once plugin_dir_path(__FILE__) . 'bbaa_front/bbaa_login_process.php'; 82 } 83 // Enqueue Style and Scripts 84 function bbaa_enqueue_script_front() 85 { 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 //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 ); 99 wp_localize_script('bbaa-script', 'bbaton_anonymous_age_verification', array( 100 'ajax_url' => admin_url('admin-ajax.php'), 101 'iamport_merchant_id' => 'imp34765018', 102 'site_url' => get_site_url(), 103 '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')) ), 106 'redirect_uri' => sanitize_text_field(get_option('bbaa_redirect_url')) 107 )); 108 } 109 // Lock Page 110 function bbaa_lock_page_content($content) 111 { 112 113 global $_COOKIE; 114 if (isset($_COOKIE['bbaton_anonymous_age_verification_confirmed']) && $_COOKIE['bbaton_anonymous_age_verification_confirmed']) return $content; 115 $heading = sanitize_text_field(get_option('bbaa_headings')); 116 $bbaa_lock_pages = get_option('bbaa_lock_pages', array( 117 'pages' => [] 118 )); 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); 197 } 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); 213 } 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_url 220 // }; 221 // // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 222 // 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 <?php 267 //include_once __DIR__."/login-page.php"; 268 return $content; 269 270 }else{ 271 return include_once __DIR__."/login-page.php"; 272 } 273 } else { 274 return $content; 275 } 276 } else { 277 return $content; 278 } 279 } 280 function bbaa_analyze_child() 281 { 282 $bbaa_lock_pages = get_option('bbaa_lock_pages', array( 283 'pages' => [] 284 )); 285 $array = array(); 286 foreach ($bbaa_lock_pages['pages'] as $page) 287 { 288 array_push($array, $page); 289 $mypages = get_pages(array( 290 'child_of' => $page 291 )); 292 $i = 0; 293 foreach ($mypages as $page) 294 { 295 array_push($array, $page->ID); 296 $i++; 297 } 298 } 299 $bbaa_lock_pages['pages'] = $array; 300 update_option("bbaa_lock_pages", $bbaa_lock_pages); 301 } 302 /** 150 303 * Display message on page to user to confirm age and Connect to bbaton.com to make auth operation 151 304 * 152 305 */ 153 function bbaa_redirect_back()154 {155 // if(isset($_GET['iamport_response_code'])){156 // $code = sanitize_text_field($_GET['iamport_response_code']);157 // $path = '/';158 // $domain = parse_url(get_option('siteurl') , PHP_URL_HOST);159 // setcookie('bbaton_anonymous_age_verification_confirmed', $code, time() + 86400, $path, $domain);160 // echo '<script>161 // var redirectURL = "' . home_url() . '";162 // if (typeof(Storage) !== "undefined" && localStorage.getItem("bbaton_anonymous_age_verification_last_url")) {163 // redirectURL = localStorage.getItem("bbaton_anonymous_age_verification_last_url");164 // }165 // window.location.replace(redirectURL);166 // </script>';167 // die();168 // }169 if (isset($_GET['code']))170 {171 $code = sanitize_text_field($_GET['code']);172 $url = 'http://bauth.bbaton.com/oauth/token';173 $client_id = sanitize_text_field(get_option('bbaa_client_id'));174 $client_secret = sanitize_text_field(get_option('bbaa_client_secret'));175 $redirect_uri = sanitize_text_field(get_option('bbaa_redirect_url'));176 $basicauth = 'Basic ' . base64_encode($client_id . ':' . $client_secret);177 $headers = array(178 'Authorization' => $basicauth,179 'Content-type' => 'application/x-www-form-urlencoded'180 );181 $response = wp_remote_post($url, array(182 'method' => 'POST',183 'timeout' => 60,184 'redirection' => 5,185 'httpversion' => '1.0',186 'blocking' => true,187 'headers' => $headers,188 'body' => array(189 'grant_type' => 'authorization_code',190 'redirect_uri' => $redirect_uri,191 'code' => $code192 ) ,193 'cookies' => array()194 ));195 $body = wp_remote_retrieve_body($response);196 $data = json_decode($body);197 if (!empty($data))198 {199 $url1 = 'http://bapi.bbaton.com/v1/user/me';200 $token = $data->access_token;201 $response = wp_remote_get($url1, array(202 'headers' => array(203 'Authorization' => "Bearer " . $token204 ) ,205 ));206 $flagJson = wp_remote_retrieve_body($response);207 $result = json_decode($flagJson);208 if ($result->adult_flag == '"Y"')209 {210 $path = '/';211 $domain = parse_url(get_option('siteurl') , PHP_URL_HOST);212 setcookie('bbaton_anonymous_age_verification_confirmed', $code, time() + 86400, $path, $domain);213 }214 echo '<script>306 function bbaa_redirect_back() 307 { 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 { 324 $code = sanitize_text_field($_GET['code']); 325 $url = 'http://bauth.bbaton.com/oauth/token'; 326 $client_id = sanitize_text_field(get_option('bbaa_client_id')); 327 $client_secret = sanitize_text_field(get_option('bbaa_client_secret')); 328 $redirect_uri = sanitize_text_field(get_option('bbaa_redirect_url')); 329 $basicauth = 'Basic ' . base64_encode($client_id . ':' . $client_secret); 330 $headers = array( 331 'Authorization' => $basicauth, 332 'Content-type' => 'application/x-www-form-urlencoded' 333 ); 334 $response = wp_remote_post($url, array( 335 'method' => 'POST', 336 'timeout' => 60, 337 'redirection' => 5, 338 'httpversion' => '1.0', 339 'blocking' => true, 340 'headers' => $headers, 341 'body' => array( 342 'grant_type' => 'authorization_code', 343 'redirect_uri' => $redirect_uri, 344 'code' => $code 345 ) , 346 'cookies' => array() 347 )); 348 $body = wp_remote_retrieve_body($response); 349 $data = json_decode($body); 350 if (!empty($data)) 351 { 352 $url1 = 'http://bapi.bbaton.com/v1/user/me'; 353 $token = $data->access_token; 354 $response = wp_remote_get($url1, array( 355 'headers' => array( 356 'Authorization' => "Bearer " . $token 357 ) , 358 )); 359 $flagJson = wp_remote_retrieve_body($response); 360 $result = json_decode($flagJson); 361 if ($result->adult_flag == '"Y"') 362 { 363 $path = '/'; 364 $domain = parse_url(get_option('siteurl') , PHP_URL_HOST); 365 setcookie('bbaton_anonymous_age_verification_confirmed', $code, time() + 86400, $path, $domain); 366 } 367 echo '<script> 215 368 var redirectURL = "' . home_url() . '"; 216 369 if (typeof(Storage) !== "undefined" && localStorage.getItem("bbaton_anonymous_age_verification_last_url")) { … … 220 373 self.close(); 221 374 </script>'; 222 die();223 }224 }225 }226 }227 $obj = new BBatonAnonymousAgeVerification();375 die(); 376 } 377 } 378 } 379 } 380 $obj = new BBatonAnonymousAgeVerification(); 228 381 } -
bbaton-anonymous-age-verification/trunk/login-page.php
r2483497 r2579604 1 <?php require(dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php');?> 2 1 3 <link href="https://fonts.googleapis.com/css2?family=Nanum+Gothic&display=swap" rel="stylesheet"> 2 4 <link href="<?php echo plugins_url('assets/css/bbaa.css?ver=2.5', __FILE__); ?>" rel="stylesheet"> … … 89 91 </div> 90 92 <script> 91 jQuery("header").remove();92 jQuery("#header-top-bar").remove();93 jQuery("header").remove(); 94 jQuery("#header-top-bar").remove(); 93 95 </script> -
bbaton-anonymous-age-verification/trunk/readme.txt
r2409400 r2579604 3 3 Tags: 비바톤, 성인인증, 게시판, 한국형게시판, board, forum, age verification, bbaton 4 4 Requires at least: 5.3 5 Tested up to: 5. 46 Requires PHP: 5.6.205 Tested up to: 5.8 6 Requires PHP: 7.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 56 56 = 1.4 = 57 57 * 버그 수정 (모바일 스크롤링) 58 59 = 2.6 = 60 * 적용페이지 미리보기
Note: See TracChangeset
for help on using the changeset viewer.