PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / manageapiuser / tmpl / default_application.php
vikappointments / admin / views / manageapiuser / tmpl Last commit date
default.php 5 days ago default_application.php 5 days ago default_ip.php 5 days ago default_plugins.php 5 days ago index.html 5 days ago
default_application.php
191 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 $user = $this->user;
15
16 $vik = VAPApplication::getInstance();
17
18 ?>
19
20 <!-- APPLICATION - Text -->
21
22 <?php echo $vik->openControl(JText::translate('VAPMANAGEAPIUSER2')); ?>
23 <input type="text" name="application" class="input-xxlarge input-large-text" value="<?php echo $this->escape($user->application); ?>" size="40" />
24 <?php echo $vik->closeControl(); ?>
25
26 <!-- USERNAME - Text -->
27
28 <?php echo $vik->openControl(JText::translate('VAPMANAGEAPIUSER3') . '*'); ?>
29 <input type="text" name="username" class="required" value="<?php echo $this->escape($user->username); ?>" size="40" />
30 <?php echo $vik->closeControl(); ?>
31
32 <!-- USERNAME REGEX - Label -->
33
34 <?php
35 $control = array();
36 $control['idparent'] = 'user-regex';
37 $control['style'] = 'display: none;';
38
39 echo $vik->openControl('', 'vap-user-regex', $control); ?>
40 <span style="color: #900; font-size: 95%;"><?php echo JText::translate('VAPAPIUSERUSERNAMEREGEX'); ?></span>
41 <?php echo $vik->closeControl(); ?>
42
43 <!-- PASSWORD - Password -->
44
45 <?php echo $vik->openControl(JText::translate('VAPMANAGECUSTOMER13') . '*'); ?>
46 <div class="input-append">
47 <input type="password" name="password" class="required" value="<?php echo $this->escape($user->password); ?>" size="40" />
48
49 <button type="button" class="btn" id="pwd-reveal-btn"><i class="fas fa-eye"></i></button>
50 </div>
51 <?php echo $vik->closeControl(); ?>
52
53 <!-- PASSWORD REGEX - Label -->
54
55 <?php
56 $control = array();
57 $control['idparent'] = 'pwd-regex';
58 $control['style'] = 'display: none;';
59
60 echo $vik->openControl('', 'vap-pwd-regex', $control); ?>
61 <span style="color: #900; font-size: 95%;"><?php echo JText::translate('VAPAPIUSERPASSWORDREGEX'); ?></span>
62 <?php echo $vik->closeControl(); ?>
63
64 <!-- GENERATE PASSWORD - Button -->
65
66 <?php echo $vik->openControl(''); ?>
67 <button type="button" class="btn" id="pwd-gen-btn"><?php echo JText::translate('VAPMANAGECUSTOMER17'); ?></button>
68 <?php echo $vik->closeControl(); ?>
69
70 <!-- ACTIVE - Checkbox -->
71
72 <?php
73 $yes = $vik->initRadioElement('', '', $user->active == 1);
74 $no = $vik->initRadioElement('', '', $user->active == 0);
75
76 echo $vik->openControl(JText::translate('VAPACTIVE'));
77 echo $vik->radioYesNo('active', $yes, $no, false);
78 echo $vik->closeControl();
79 ?>
80
81 <?php
82 JText::script('JGLOBAL_SELECT_AN_OPTION');
83 ?>
84
85 <script>
86
87 jQuery(function($) {
88 $('#pwd-reveal-btn').on('click', function() {
89 var icon = $(this).find('i');
90
91 if (icon.hasClass('fa-eye')) {
92 $('input[name="password"]').attr('type', 'text');
93 icon.removeClass('fa-eye').addClass('fa-eye-slash');
94 } else {
95 $('input[name="password"]').attr('type', 'password');
96 icon.removeClass('fa-eye-slash').addClass('fa-eye');
97 }
98 });
99
100 String.prototype.shuffle = function() {
101 var a = this.split('');
102
103 for (var i = a.length - 1, j = 0, tmp = 0; i >= 0; i--) {
104 j = Math.floor(Math.random() * (i + 1));
105
106 tmp = a[i];
107 a[i] = a[j];
108 a[j] = tmp;
109 }
110
111 return a.join('');
112 }
113
114 const buildPassword = (min_length, max_length, min_digits, min_uppercase, chars_str) => {
115 var pwd = '';
116
117 var len = Math.min(24, ( min_length + max_length ) / 2);
118
119 var i;
120
121 for (i = 0; i < min_digits; i++) {
122 pwd += '' + Math.floor(Math.random() * 10);
123 }
124
125 for (i = 0; i < min_uppercase; i++) {
126 pwd += String.fromCharCode(65 + Math.floor(Math.random() * 26));
127 }
128
129 for (i = pwd.length; i < len; i++) {
130 pwd += chars_str.charAt(Math.floor(Math.random() * chars_str.length));
131 }
132
133 return pwd.shuffle();
134 };
135
136 $('#pwd-gen-btn').on('click', () => {
137 var password = buildPassword(8, 128, 1, 1, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
138
139 $('input[name="password"]').val(password);
140
141 if ($('input[name="password"]').attr('type') == 'password') {
142 $('#pwd-reveal-btn').trigger('click');
143 }
144
145 $('#pwd-regex').hide();
146 validator.validate();
147 });
148
149 // validate username
150 validator.addCallback(() => {
151 var userInput = $('input[name="username"]');
152 var user = userInput.val();
153
154 if (typeof user !== 'string') {
155 user = '';
156 }
157
158 if (user.match(/^[0-9A-Za-z._]{3,128}$/)) {
159 validator.unsetInvalid(userInput);
160 $('#user-regex').hide();
161 return true;
162 }
163
164 validator.setInvalid(userInput);
165 $('#user-regex').show();
166 return false;
167 });
168
169 // validate password
170 validator.addCallback(() => {
171 var pwdInput = $('input[name="password"]');
172 var pwd = pwdInput.val();
173
174 if (typeof pwd !== 'string') {
175 pwd = '';
176 }
177
178 if (pwd.match(/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!?@#$%_.\-{\[()\]}]{8,128}$/)) {
179 validator.unsetInvalid(pwdInput);
180 $('#pwd-regex').hide();
181 return true;
182 }
183
184 validator.setInvalid(pwdInput);
185 $('#pwd-regex').show();
186 return false;
187 });
188 });
189
190 </script>
191