function show_form($data = null) { if (empty($data['phone_method'])) { $data['phone_method'] = 'sms'; } $form = new Form(); $form->start($data); $form->errors($this->err_flds); if (!$this->is_logged_in()) { $form->text('userid', 'Desired User ID:', 15, 'UserID'); $form->text('pw1', 'Password:'******'Password', true, true); $form->password_strength('pw1', ''); $form->text('pw2', 'Repeat:', 50, 'Password', true, true); } $form->text('first', 'First Name:', 25, 'First Name'); $form->hspace(3); $form->text('last', 'Last Name:', 25, 'Last Name', false); $form->text('email', 'Email:', 75, '*****@*****.**'); $form->text('phone', 'Verification Phone:', 25, '303-555-1234'); $form->radio('phone_method', 'SMS (text)', 'sms'); $form->hspace(5); $form->radio('phone_method', 'Voice', 'voice', false); $form->button('action_register', $this->is_logged_in() ? 'Save' : 'Register'); // Next line for clickjacking example //$form->button('action_disable', 'Disable 2FA'); $form->end(); $userid = isset($data['userid']) ? $data['userid'] : ''; echo <<<EOT <script> \$('#pw1').bind('keydown', function() { PasswordDidChange('pw1', '{$userid}'); }); </script> EOT; }
function show_form($data = null) { $new = is_null($data); if (empty($data['phone_method'])) { $data['phone_method'] = 'sms'; } $f = new Form(); $f->start($data); $f->errors($this->err_flds); $f->hidden('new', $new ? '1' : '0'); if ($new) { $readonly = false; $userid = ''; } else { $readonly = true; $userid = $data['userid']; } $f->text('userid', 'User ID:', 25, 'User ID', true, false, $readonly); $f->text('first', 'First Name:', 25, 'First Name'); $f->hspace(3); $f->text('last', 'Last Name:', 25, 'Last Name', false); $f->text('email', 'Email:', 75, '*****@*****.**'); $f->text('phone', 'Verification Phone:', 25, '303-555-1234'); $f->radio('phone_method', 'SMS (text)', 'sms'); $f->hspace(5); $f->radio('phone_method', 'Voice', 'voice', false); echo '<p class=label>Roles:'; if ($new && false) { $stmt = $this->db->query('select * from role order by role'); } else { $stmt = $this->db->query('select * from role left join (select * from user_role where userid = :userid) as ur using (role) order by role', array('userid' => $userid)); } for ($n = 1; $row = $stmt->fetch(); $n++) { echo '<br>'; $fld = "fld_{$n}"; $checked = isset($row['userid']) ? 'checked' : ''; echo "<input id={$fld} type=checkbox name=role[]\n value={$row['role']} {$checked}>"; $f->label($fld, $row['role'], false); } $f->button('action_save', 'Save'); $f->end(); $this->ac->show_permissions($userid); }