| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * PHPPgAdmin 6.1.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | namespace PHPPgAdmin\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPPgAdmin\Decorators\Decorator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Base controller class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | class UsersController extends BaseController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     public $controller_title = 'strusers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * Default method to render the controller according to the action parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public function render(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $this->printHeader(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->printBody(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         switch ($this->action) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |             case 'changepassword': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |                 if (isset($_REQUEST['ok'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |                     $this->doChangePassword(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                     $this->doAccount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             case 'confchangepassword': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |                 $this->doChangePassword(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             case 'account': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 $this->doAccount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             case 'save_create': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 if (isset($_REQUEST['cancel'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                     $this->doDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                     $this->doSaveCreate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             case 'create': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 $this->doCreate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             case 'drop': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                 if (isset($_REQUEST['cancel'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                     $this->doDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                     $this->doDrop(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             case 'confirm_drop': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                 $this->doDrop(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             case 'save_edit': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                 if (isset($_REQUEST['cancel'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                     $this->doDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                     $this->doSaveEdit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             case 'edit': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 $this->doEdit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 $this->doDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->printFooter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * Show default list of users in the database. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * @param mixed $msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     public function doDefault($msg = ''): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $lang = $this->lang; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $renderUseExpires = static function ($val) use ($lang) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             return 'infinity' === $val ? $lang['strnever'] : \htmlspecialchars($val); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->printTrail('server'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->printTabs('server', 'users'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->printMsg($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $users = $data->getUsers(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         $columns = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             'user' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                 'title' => $this->lang['strusername'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                 'field' => Decorator::field('usename'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             'group' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                 'title' => $this->lang['strgroup'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 'field' => Decorator::field('group'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             'superuser' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                 'title' => $this->lang['strsuper'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 'field' => Decorator::field('usesuper'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                 'type' => 'yesno', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             'createdb' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 'title' => $this->lang['strcreatedb'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 'field' => Decorator::field('usecreatedb'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 'type' => 'yesno', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             'expires' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                 'title' => $this->lang['strexpires'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                 'field' => Decorator::field('useexpires'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 'type' => 'callback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 'params' => ['function' => $renderUseExpires, 'null' => $this->lang['strnever']], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             'defaults' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                 'title' => $this->lang['strsessiondefaults'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 'field' => Decorator::field('useconfig'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             'actions' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                 'title' => $this->lang['stractions'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $actions = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             'alter' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                 'content' => $this->lang['stralter'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                 'attr' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                     'href' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                         'url' => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                         'urlvars' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                             'action' => 'edit', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                             'username' => Decorator::field('usename'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                     ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             'drop' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 'content' => $this->lang['strdrop'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 'attr' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                     'href' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                         'url' => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                         'urlvars' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                             'action' => 'confirm_drop', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                             'username' => Decorator::field('usename'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                     ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         echo $this->printTable($users, $columns, $actions, 'users-users', $this->lang['strnousers']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $this->printNavLinks(['create' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             'attr' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 'href' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                     'url' => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |                     'urlvars' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                         'action' => 'create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                         'server' => $_REQUEST['server'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                     ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             'content' => $this->lang['strcreateuser'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         ]], 'users-users', \get_defined_vars()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * If a user is not a superuser, then we have an 'account management' page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * where they can change their password, etc.  We don't prevent them from | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * messing with the URL to gain access to other user admin stuff, because | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * the PostgreSQL permissions will prevent them changing anything anyway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @param mixed $msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     public function doAccount($msg = ''): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $server_info = $this->misc->getServerInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $userdata = $data->getUser($server_info['username']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         $_REQUEST['user'] = $server_info['username']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $this->printTrail('user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $this->printTabs('server', 'account'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $this->printMsg($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         if (0 < $userdata->RecordCount()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $userdata->fields['usesuper'] = $data->phpBool($userdata->fields['usesuper']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             echo '<table>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 '<tr><th class="data">%s</th><th class="data">%s</th><th class="data">%s</th><th class="data">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                 $this->lang['strusername'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                 $this->lang['strsuper'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 $this->lang['strcreatedb'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                 $this->lang['strexpires'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                 '<th class="data">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                 $this->lang['strsessiondefaults'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             echo '</tr>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             echo "<tr>\n\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usename']), '</td>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usesuper'], 'yesno'), '</td>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usecreatedb'], 'yesno'), '</td>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             echo "\t<td class=\"data1\">", ('infinity' === $userdata->fields['useexpires'] || null === $userdata->fields['useexpires'] ? $this->lang['strnever'] : $this->misc->printVal($userdata->fields['useexpires'])), '</td>' . \PHP_EOL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['useconfig']), '</td>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             echo "</tr>\n</table>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                 '<p>%s</p>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                 $this->lang['strnodata'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $this->printNavLinks(['changepassword' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             'attr' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                 'href' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                     'url' => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                     'urlvars' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                         'action' => 'confchangepassword', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                         'server' => $_REQUEST['server'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                     ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             'content' => $this->lang['strchangepassword'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         ]], 'users-account', \get_defined_vars()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * Show confirmation of change password and actually change password. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |      * @param mixed $confirm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |      * @param mixed $msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     public function doChangePassword($confirm, $msg = ''): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         $server_info = $this->misc->getServerInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         if ($confirm) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             $_REQUEST['user'] = $server_info['username']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             $this->printTrail('user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             $this->printTitle($this->lang['strchangepassword'], 'pg.user.alter'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             $this->printMsg($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             $this->coalesceArr($_POST, 'password', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |             $this->coalesceArr($_POST, 'confirm', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             echo '<form action="' . \containerInstance()->subFolder . '/src/views/users" method="post">' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             echo '<table>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |                 '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 		<th class="data left required">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |                 $this->lang['strpassword'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             echo "\t\t<td><input type=\"password\" name=\"password\" size=\"32\" value=\"", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                 \htmlspecialchars($_POST['password']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |                 "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                 '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		<th class="data left required">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                 $this->lang['strconfirm'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             echo "\t\t<td><input type=\"password\" name=\"confirm\" size=\"32\" value=\"\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             echo '</table>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |             echo '<p><input type="hidden" name="action" value="changepassword" />' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |             echo $this->view->form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 '<input type="submit" name="ok" value="%s" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                 $this->lang['strok'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |                 '<input type="submit" name="cancel" value="%s" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                 $this->lang['strcancel'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             echo '</p></form>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             // Check that password is minimum length | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             if (\mb_strlen($_POST['password']) < $this->conf['min_password_length']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                 $this->doChangePassword(true, $this->lang['strpasswordshort']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             } elseif ($_POST['password'] !== $_POST['confirm']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                 // Check that password matches confirmation password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                 $this->doChangePassword(true, $this->lang['strpasswordconfirm']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |                 $status = $data->changePassword( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |                     $server_info['username'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |                     $_POST['password'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |                 if (0 === $status) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |                     $this->doAccount($this->lang['strpasswordchanged']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |                     $this->doAccount($this->lang['strpasswordchangedbad']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      * Function to allow editing of a user. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      * @param mixed $msg | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 326 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |     public function doEdit($msg = ''): void | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |         $this->printTrail('user'); | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |         $this->printTitle($this->lang['stralter'], 'pg.user.alter'); | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |         $this->printMsg($msg); | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |         $userdata = $data->getUser($_REQUEST['username']); | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |         if (!\is_object($userdata) || 0 < $userdata->RecordCount()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |             $server_info = $this->misc->getServerInfo(); | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |             $canRename = $data->hasUserRename() && ($_REQUEST['username'] !== $server_info['username']); | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |             $userdata->fields['usesuper'] = $data->phpBool($userdata->fields['usesuper'] ?? false); | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |             $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb'] ?? false); | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |             if (!isset($_POST['formExpires'])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |                 if ($canRename) { | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |                     $_POST['newname'] = $userdata->fields['usename']; | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |                 if ($userdata->fields['usesuper']) { | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |                     $_POST['formSuper'] = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |                 if ($userdata->fields['usecreatedb']) { | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |                     $_POST['formCreateDB'] = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |                 $_POST['formExpires'] = 'infinity' === $userdata->fields['useexpires'] ? '' : $userdata->fields['useexpires']; | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |                 $_POST['formPassword'] = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |             echo '<form action="' . \containerInstance()->subFolder . '/src/views/users" method="post">' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |             echo '<table>' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |                 $this->lang['strusername'] | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |             echo "\t\t<td class=\"data1\">", ($canRename ? \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |                 '<input name="newname" size="15" maxlength="%s" value="', | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |                 $data->_maxNameLen | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |             ) . \htmlspecialchars($_POST['newname']) . '" />' : $this->misc->printVal($userdata->fields['usename'])), "</td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  | 		<th class="data left"><label for="formSuper">%s</label></th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |                 $this->lang['strsuper'] | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  |             echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formSuper\" name=\"formSuper\"", | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  |                 (isset($_POST['formSuper'])) ? ' checked="checked"' : '', | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  |                 " /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 380 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 381 |  |  | 		<th class="data left"><label for="formCreateDB">%s</label></th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 382 |  |  |                 $this->lang['strcreatedb'] | 
            
                                                                        
                            
            
                                    
            
            
                | 383 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 384 |  |  |             echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formCreateDB\" name=\"formCreateDB\"", | 
            
                                                                        
                            
            
                                    
            
            
                | 385 |  |  |                 (isset($_POST['formCreateDB'])) ? ' checked="checked"' : '', | 
            
                                                                        
                            
            
                                    
            
            
                | 386 |  |  |                 " /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 387 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 388 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 389 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 390 |  |  |                 $this->lang['strexpires'] | 
            
                                                                        
                            
            
                                    
            
            
                | 391 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 392 |  |  |             echo "\t\t<td class=\"data1\"><input size=\"16\" name=\"formExpires\" value=\"", \htmlspecialchars($_POST['formExpires']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 393 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 394 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 395 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 396 |  |  |                 $this->lang['strpassword'] | 
            
                                                                        
                            
            
                                    
            
            
                | 397 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 398 |  |  |             echo "\t\t<td class=\"data1\"><input type=\"password\" size=\"16\" name=\"formPassword\" value=\"", \htmlspecialchars($_POST['formPassword']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 399 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 400 |  |  |                 '	<tr> | 
            
                                                                        
                            
            
                                    
            
            
                | 401 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                        
                            
            
                                    
            
            
                | 402 |  |  |                 $this->lang['strconfirm'] | 
            
                                                                        
                            
            
                                    
            
            
                | 403 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 404 |  |  |             echo "\t\t<td class=\"data1\"><input type=\"password\" size=\"16\" name=\"formConfirm\" value=\"\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 405 |  |  |             echo '</table>' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 406 |  |  |             echo '<p><input type="hidden" name="action" value="save_edit" />' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 407 |  |  |             echo '<input type="hidden" name="username" value="', \htmlspecialchars($_REQUEST['username']), '" />' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 408 |  |  |             echo $this->view->form; | 
            
                                                                        
                            
            
                                    
            
            
                | 409 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 410 |  |  |                 '<input type="submit" name="alter" value="%s" />', | 
            
                                                                        
                            
            
                                    
            
            
                | 411 |  |  |                 $this->lang['stralter'] | 
            
                                                                        
                            
            
                                    
            
            
                | 412 |  |  |             ) . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 413 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 414 |  |  |                 '<input type="submit" name="cancel" value="%s"  /></p>%s', | 
            
                                                                        
                            
            
                                    
            
            
                | 415 |  |  |                 $this->lang['strcancel'], | 
            
                                                                        
                            
            
                                    
            
            
                | 416 |  |  |                 \PHP_EOL | 
            
                                                                        
                            
            
                                    
            
            
                | 417 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 418 |  |  |             echo '</form>' . \PHP_EOL; | 
            
                                                                        
                            
            
                                    
            
            
                | 419 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 420 |  |  |             echo \sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 421 |  |  |                 '<p>%s</p>', | 
            
                                                                        
                            
            
                                    
            
            
                | 422 |  |  |                 $this->lang['strnodata'] | 
            
                                                                        
                            
            
                                    
            
            
                | 423 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |      * Function to save after editing a user. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |     public function doSaveEdit(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         // Check name and password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         if (isset($_POST['newname']) && '' === $_POST['newname']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |             $this->doEdit($this->lang['struserneedsname']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         } elseif ($_POST['formPassword'] !== $_POST['formConfirm']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |             $this->doEdit($this->lang['strpasswordconfirm']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |             if (isset($_POST['newname'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                 $status = $data->setRenameUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires'], $_POST['newname']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |                 $status = $data->setUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |             if (0 === $status) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |                 $this->doDefault($this->lang['struserupdated']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                 $this->doEdit($this->lang['struserupdatedbad']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |      * Show confirmation of drop and perform actual drop. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |      * @param mixed $confirm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |     public function doDrop($confirm): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |         if ($confirm) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |             $this->printTrail('user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             $this->printTitle($this->lang['strdrop'], 'pg.user.drop'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             echo '<p>', \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |                 $this->lang['strconfdropuser'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |                 $this->misc->printVal($_REQUEST['username']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |             ), '</p>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |             echo '<form action="' . \containerInstance()->subFolder . '/src/views/users" method="post">' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             echo '<p><input type="hidden" name="action" value="drop" />' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |             echo '<input type="hidden" name="username" value="', \htmlspecialchars($_REQUEST['username']), '" />' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             echo $this->view->form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                 '<input type="submit" name="drop" value="%s" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                 $this->lang['strdrop'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |             ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |             echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |                 '<input type="submit" name="cancel" value="%s"  /></p>%s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                 $this->lang['strcancel'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |                 \PHP_EOL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |             echo '</form>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             $status = $data->dropUser($_REQUEST['username']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |             if (0 === $status) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                 $this->doDefault($this->lang['struserdropped']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                 $this->doDefault($this->lang['struserdroppedbad']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |      * Displays a screen where they can enter a new user. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |      * @param mixed $msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     public function doCreate($msg = ''): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $this->coalesceArr($_POST, 'formUsername', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $this->coalesceArr($_POST, 'formPassword', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $this->coalesceArr($_POST, 'formConfirm', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         $this->coalesceArr($_POST, 'formExpires', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $this->printTrail('server'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |         $this->printTitle($this->lang['strcreateuser'], 'pg.user.create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         $this->printMsg($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |         echo '<form action="' . \containerInstance()->subFolder . '/src/views/users" method="post">' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         echo '<table>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 		<th class="data left required">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |             $this->lang['strusername'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |             '		<td class="data1"><input size="15" maxlength="%s" name="formUsername" value="', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |             $data->_maxNameLen | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         ), \htmlspecialchars($_POST['formUsername']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |             $this->lang['strpassword'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         echo "\t\t<td class=\"data1\"><input size=\"15\" type=\"password\" name=\"formPassword\" value=\"", \htmlspecialchars($_POST['formPassword']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |             $this->lang['strconfirm'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |         echo "\t\t<td class=\"data1\"><input size=\"15\" type=\"password\" name=\"formConfirm\" value=\"", \htmlspecialchars($_POST['formConfirm']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 		<th class="data left"><label for="formSuper">%s</label></th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |             $this->lang['strsuper'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formSuper\" name=\"formSuper\"", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |             (isset($_POST['formSuper'])) ? ' checked="checked"' : '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |             " /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 		<th class="data left"><label for="formCreateDB">%s</label></th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |             $this->lang['strcreatedb'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |         echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formCreateDB\" name=\"formCreateDB\"", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |             (isset($_POST['formCreateDB'])) ? ' checked="checked"' : '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |             " /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |             '	<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 		<th class="data left">%s</th>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |             $this->lang['strexpires'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |         echo "\t\t<td class=\"data1\"><input size=\"30\" name=\"formExpires\" value=\"", \htmlspecialchars($_POST['formExpires']), "\" /></td>\n\t</tr>" . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |         echo '</table>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         echo '<p><input type="hidden" name="action" value="save_create" />' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |         echo $this->view->form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |             '<input type="submit" name="create" value="%s" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |             $this->lang['strcreate'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |         ) . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         echo \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |             '<input type="submit" name="cancel" value="%s"  /></p>%s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |             $this->lang['strcancel'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |             \PHP_EOL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         echo '</form>' . \PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |      * Actually creates the new user in the database. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |     public function doSaveCreate(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |         $data = $this->misc->getDatabaseAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |         // Check data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |         if ('' === $_POST['formUsername']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |             $this->doCreate($this->lang['struserneedsname']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |         } elseif ($_POST['formPassword'] !== $_POST['formConfirm']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |             $this->doCreate($this->lang['strpasswordconfirm']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |             $status = $data->createUser( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |                 $_POST['formUsername'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |                 $_POST['formPassword'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |                 isset($_POST['formCreateDB']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |                 isset($_POST['formSuper']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |                 $_POST['formExpires'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |                 [] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |             if (0 === $status) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |                 $this->doDefault($this->lang['strusercreated']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |                 $this->doCreate($this->lang['strusercreatedbad']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 607 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 608 |  |  |  |