PluginProbe
Welcart e-Commerce / 2.11.31
Welcart e-Commerce v2.11.31
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / extensions / CreditCardSecurity / class-creditcard-security.php

class-creditcard-security.php in Welcart e-Commerce 2.11.31, at extensions/CreditCardSecurity/class-creditcard-security.php

205 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CreditCard Security Measures class
4 *
5 * @package Welcart
6 */
7
8 /**
9 * CreditCard Security Measures class
10 */
11 class USCES_CREDITCARD_SECURITY {
12
13 /**
14 * Option value
15 *
16 * @var array
17 */
18 public static $option;
19
20 /**
21 * Default option value
22 *
23 * @var array
24 */
25 public static $default_option;
26
27 /**
28 * Class Constructor
29 */
30 public function __construct() {
31
32 self::initialize_data();
33
34 if ( is_admin() ) {
35 add_action( 'usces_action_admin_system_extentions', array( $this, 'setting_form' ) );
36 add_action( 'init', array( $this, 'save_data' ) );
37 add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
38 }
39 }
40
41 /**
42 * Initialize
43 */
44 public function initialize_data() {
45
46 self::$default_option = array(
47 'time_frame' => array( 15, 30, 60, 120 ),
48 'set_count' => array( 2, 5, 10, 15, 20 ),
49 'lockout_time' => array( 1, 6, 12, 24 ),
50 );
51
52 $ex_option = get_option( 'usces_ex', array() );
53 $ex_option['system']['credit_security']['active'] = ( isset( $ex_option['system']['credit_security']['active'] ) ) ? (int) $ex_option['system']['credit_security']['active'] : 1;
54 $ex_option['system']['credit_security']['time_frame'] = ( isset( $ex_option['system']['credit_security']['time_frame'] ) ) ? (int) $ex_option['system']['credit_security']['time_frame'] : self::$default_option['time_frame'][0];
55 $ex_option['system']['credit_security']['set_count'] = ( isset( $ex_option['system']['credit_security']['set_count'] ) ) ? (int) $ex_option['system']['credit_security']['set_count'] : self::$default_option['set_count'][1];
56 $ex_option['system']['credit_security']['lockout_time'] = ( isset( $ex_option['system']['credit_security']['lockout_time'] ) ) ? (int) $ex_option['system']['credit_security']['lockout_time'] : self::$default_option['lockout_time'][0];
57 update_option( 'usces_ex', $ex_option );
58 self::$option = $ex_option['system']['credit_security'];
59 }
60
61 /**
62 * Save option value
63 * init
64 */
65 public function save_data() {
66 global $usces;
67
68 if ( isset( $_POST['usces_credit_security_option_update'] ) ) {
69 check_admin_referer( 'admin_system', 'wc_nonce' );
70 if ( ! current_user_can( 'wel_manage_setting' ) ) {
71 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
72 }
73
74 self::$option['active'] = ( isset( $_POST['credit_security_active'] ) ) ? (int) $_POST['credit_security_active'] : 1;
75 self::$option['time_frame'] = ( isset( $_POST['credit_security_time_frame'] ) ) ? (int) $_POST['credit_security_time_frame'] : self::$default_option['time_frame'][0];
76 self::$option['set_count'] = ( isset( $_POST['credit_security_set_count'] ) ) ? (int) $_POST['credit_security_set_count'] : self::$default_option['set_count'][1];
77 self::$option['lockout_time'] = ( isset( $_POST['credit_security_lockout_time'] ) ) ? (int) $_POST['credit_security_lockout_time'] : self::$default_option['lockout_time'][0];
78
79 $ex_option = get_option( 'usces_ex', array() );
80 $ex_option['system']['credit_security'] = self::$option;
81 update_option( 'usces_ex', $ex_option );
82 }
83 }
84
85 /**
86 * Setting form
87 * usces_action_admin_system_extentions
88 */
89 public function setting_form() {
90 $active = ( 1 === self::$option['active'] ) ? '<span class="running">' . __( 'Running', 'usces' ) . '</span>' : '<span class="stopped">' . __( 'Stopped', 'usces' ) . '</span>';
91 ?>
92 <form action="" method="post" name="option_form" id="credit_security_form">
93 <div class="postbox">
94 <div class="postbox-header">
95 <h2><span><?php esc_html_e( 'Credit Card Security Measures', 'usces' ); ?></span><?php wel_esc_script_e( $active ); ?></h2>
96 <div class="handle-actions"><button type="button" class="handlediv" id="credit_security"><span class="screen-reader-text"><?php echo esc_html( sprintf( __( 'Toggle panel: %s' ), __( 'Security measures', 'usces' ) ) ); ?></span><span class="toggle-indicator"></span></button></div>
97 </div>
98 <div class="inside">
99 <table class="form_table">
100 <tr>
101 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility('ex_credit_security_active');"><?php esc_html_e( 'Credit Master Measure', 'usces' ); ?></a></th>
102 <td width="10"><input name="credit_security_active" type="radio" id="credit_security_active_0" value="0"<?php checked( self::$option['active'], 0 ); ?> /></td>
103 <td width="100"><label for="credit_security_active_0"><?php esc_html_e( 'disable', 'usces' ); ?></label></td>
104 <td width="10"><input name="credit_security_active" type="radio" id="credit_security_active_1" value="1"<?php checked( self::$option['active'], 1 ); ?> /></td>
105 <td width="100"><label for="credit_security_active_1"><?php esc_html_e( 'enable', 'usces' ); ?></label></td><td></td>
106 <td><div id="ex_credit_security_active" class="explanation"><?php esc_html_e( 'If the card information input fails (Update Count) times in (Counting time) minutes, the update lock will be applied for (Lock time) hours and the card information input will be disabled.', 'usces' ); ?></div></td>
107 </tr>
108 </table>
109 <table class="form_table" id="credit_master_form">
110 <tr height="35">
111 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility('ex_credit_security_time_frame');"><?php esc_html_e( 'Counting time', 'usces' ); ?></a></th>
112 <td><select name="credit_security_time_frame">
113 <?php foreach ( self::$default_option['time_frame'] as $value ) : ?>
114 <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $value, self::$option['time_frame'] ); ?>><?php echo esc_html( $value ); ?></option>
115 <?php endforeach; ?>
116 </select><label for="credit_security_time_frame"><?php esc_html_e( 'min', 'usces' ); ?></label></td>
117 <td><div id="ex_credit_security_time_frame" class="explanation"><?php esc_html_e( 'Time to count updates (minutes)', 'usces' ); ?></div></td>
118 </tr>
119 <tr height="35">
120 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility('ex_credit_security_set_count');"><?php esc_html_e( 'Update Count', 'usces' ); ?></a></th>
121 <td><select name="credit_security_set_count">
122 <?php foreach ( self::$default_option['set_count'] as $value ) : ?>
123 <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $value, self::$option['set_count'] ); ?>><?php echo esc_html( $value ); ?></option>
124 <?php endforeach; ?>
125 </select><label for="credit_security_set_count"><?php esc_html_e( 'counts', 'usces' ); ?></label></td>
126 <td><div id="ex_credit_security_set_count" class="explanation"><?php esc_html_e( 'How many times the card information update is repeated to be locked.', 'usces' ); ?></div></td>
127 </tr>
128 <tr height="35">
129 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility('ex_credit_security_lockout_time');"><?php esc_html_e( 'Lock time', 'usces' ); ?></a></th>
130 <td><select name="credit_security_lockout_time">
131 <?php foreach ( self::$default_option['lockout_time'] as $value ) : ?>
132 <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $value, self::$option['lockout_time'] ); ?>><?php echo esc_html( $value ); ?></option>
133 <?php endforeach; ?>
134 </select><label for="credit_security_lockout_time"><?php esc_html_e( 'hours', 'usces' ); ?></label></td>
135 <td><div id="ex_credit_security_lockout_time" class="explanation"><?php esc_html_e( 'Time to update lock (hours)', 'usces' ); ?></div></td>
136 </tr>
137 <tr height="35">
138 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility('ex_credit_security_unlock');"><?php esc_html_e( 'Unlock', 'usces' ); ?></a></th>
139 <td><input type="button" id="credit_security_unlock" value="<?php esc_html_e( 'Cancellation', 'usces' ); ?>" class="button"><span id="unlock-loading"></span></td>
140 <td><div id="ex_credit_security_unlock" class="explanation"><?php esc_html_e( 'Unlock all locks.', 'usces' ); ?><?php esc_html_e( 'If you wish to unlock a specific member, please unlock it from the Edit Member page.', 'usces' ); ?></div></td>
141 </tr>
142 </table>
143 <hr/>
144 <input name="usces_credit_security_option_update" type="submit" class="button button-primary" value="<?php esc_attr_e( 'change decision', 'usces' ); ?>"/>
145 </div>
146 </div><!--postbox-->
147 <?php wp_nonce_field( 'admin_system', 'wc_nonce' ); ?>
148 </form>
149 <?php
150 }
151
152 /**
153 * Admin scripts
154 * admin_print_footer_scripts
155 */
156 public function admin_scripts() {
157 $page = filter_input( INPUT_GET, 'page' );
158 if ( 'usces_system' === $page ) :
159 ?>
160 <script type="text/javascript">
161 jQuery(document).ready( function($) {
162 if( '1' == $("input[name='credit_security_active']:checked").val() ) {
163 $('#credit_master_form').css('display','');
164 } else {
165 $('#credit_master_form').css('display','none');
166 }
167 $(document).on( 'change', "input[name='credit_security_active']", function() {
168 if( '1' == $("input[name='credit_security_active']:checked").val() ) {
169 $('#credit_master_form').css('display','');
170 } else {
171 $('#credit_master_form').css('display','none');
172 }
173 });
174 $(document).on( 'click', '#credit_security_unlock', function() {
175 if( ! confirm("<?php esc_html_e( 'Unlock all locks?', 'usces' ); ?>") ) {
176 return false;
177 }
178 $('#unlock-loading').html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
179 $.ajax({
180 url: ajaxurl,
181 type: "POST",
182 cache: false,
183 dataType: 'json',
184 data: {
185 action: 'credit_security_unlock',
186 wc_nonce : '<?php echo wp_create_nonce( 'credit_security_unlock' ); ?>',
187 }
188 }).done( function( retVal, dataType ) {
189 $('#unlock-loading').html('');
190 alert("<?php esc_html_e( 'Unlocked Completed.', 'usces' ); ?>");
191 }).fail( function( jqXHR, textStatus, errorThrown ) {
192 console.log( textStatus );
193 console.log( jqXHR.status );
194 console.log( errorThrown.message );
195 $('#unlock-loading').html('');
196 });
197 return false;
198 });
199 });
200 </script>
201 <?php
202 endif;
203 }
204 }
205