Fixing a few things found whilst setting up demo
[PHPCredLocker.git] / modules / search-table / search-table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php 
/** Part of Menu module - Table containing data used for search and menu generation.
*
* Copyright (C) 2012 B Tasker
* Released under GNU GPL V2
* See LICENSE
*
*
* Usage: each row specifies a record to be parsed by the relevant Javascript function (usually SearchTable or CreateMenuContent)
*
*
* <tr>
*    <td>Text to Display </td>
*    <td>Highlighted item (e.g. User:)</td>
*    <td>id - the id to append to any URLS</td>
*    <td>Classification, used by CreateMenuContent 1 = Customer, 2 = Cred Type</td>
*    <td>id field - default id, used to form the URI params (so might set frmUsername when linking to user edit page)</td>
*    <td>option - used to form URI Params</td>
*    <td>Additional Params - Optional </td>
*  </tr>
*
*
*
*/ 
defined('_CREDLOCK') or die;
?>
 
<?php if (BTMain::getUser()->name):
 
  $custs = new CustDB;
  $crdtypes=new CredDB;
  $crypt = new Crypto;
  $crypt->safety = 0;
 
 
// Output a hidden table so we can use JS to build the menus and implement search funtions (avoids having the cleartext strings in Server memory more than once)
?>
 
      <!-- Search Table Begins -->
 
<table id="SearchListing" style="display: none;">
  <tr>
    <td>Add <?php echo Lang::_("Customer"); ?></td>
    <td><?php echo Lang::_("Customer"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>addCustomer</td>
  </tr>
 
  <tr>
    <td>View <?php echo Lang::_("Customers"); ?></td>
    <td><?php echo Lang::_("Customer"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>viewCustomers</td>
  </tr>
 
<?php
  foreach ($custs->getAllCustomers() as $customer){
      ob_start();
      $plaintext = $crypt->decrypt($customer->Name,'Customer');
?>
  <tr>
    <td><?php echo $plaintext; ?></td>
    <td><?php echo Lang::_("Customer"); ?>:</td>
    <td><?php echo $customer->id;?></td>
    <td>1</td>
    <td></td>
    <td>viewCust</td>
  </tr>
 
<?php
  $tbl[$plaintext] = ob_get_clean();
  }
 
 
ksort($tbl);
echo implode("\n",$tbl);
 
  if (BTMain::checkisSuperAdmin()):?>
 
  <tr>
    <td>Add <?php echo Lang::_("Credential Type"); ?></td>
    <td><?php echo Lang::_("Credential Type"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>addCredType</td>
  </tr>
 
  <tr>
    <td>View <?php echo Lang::_("Cred Types"); ?></td>
    <td><?php echo Lang::_("Credential Type"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>viewByType</td>
  </tr>
 
<?php
  endif;
 
 
  foreach ($crdtypes->getCredTypes() as $credtype){
      ob_start();
      $plaintext = $crypt->decrypt($credtype->Name,'CredType');
    ?>
 
  <tr>
    <td><?php echo $plaintext; ?></td>
    <td><?php echo Lang::_("Credential Type"); ?>:</td>
    <td><?php echo $credtype->id;?></td>
    <td>2</td>
    <td></td>
    <td>viewByType</td>
  </tr>
 
<?php
 
  $cred[$plaintext] = ob_get_clean();
  }
 
ksort($cred);
echo implode("\n",$cred);
 
  if (BTMain::checkisSuperAdmin()):
?>
  <tr>
    <td>Add User</td>
    <td>User:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>addUser</td>
  </tr>
 
  <tr>
    <td>View Users</td>
    <td>User:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>viewUsers</td>
  </tr>
 
<?php
$auth = new AuthDB;
 
  foreach($auth->listUsers() as $user){
  ?>
 
  <tr>
    <td><?php echo $user->Name . " ({$user->username})"; ?></td>
    <td>User:</td>
    <td><?php echo $user->username;?></td>
    <td></td>
    <td>frmUsername</td>
    <td>editUser</td>
  </tr>
 
  <?php
  }
  ?>
 
 
  <tr>
    <td>Add <?php echo Lang::_("UserGroup");?></td>
    <td><?php echo Lang::_("UserGroup"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>addGrp</td>
  </tr>
 
 
  <tr>
    <td>View <?php echo Lang::_("User Groups");?></td>
    <td><?php echo Lang::_("UserGroup"); ?>:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>viewGrps</td>
  </tr>
 
<?php
 
  foreach ($auth->retrieveGroupNames() as $grp){
?>
 
  <tr>
    <td><?php echo $crypt->decrypt($grp->Name,'Groups'); ?></td>
    <td><?php echo Lang::_("UserGroup"); ?>:</td>
    <td><?php echo $grp->id;?></td>
    <td></td>
    <td></td>
    <td>editGrp</td>
  </tr>
 
  <?php
  }
 
 
?>
 <tr>
    <td>View Plugins</td>
    <td>Plugin:</td>
    <td></td>
    <td></td>
    <td></td>
    <td>pluginInfo</td>
  </tr>
<?php
 
$plug = new Plugins;
$plugins = $plug->listloadedPlugins(); 
 
      if (isset($plugins->Auth)):
          foreach($plugins->Auth as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (Authentication Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Auth</td>
  </tr>
 
        <?php
          }
 
      endif;
 
 
 
 
    if (isset($plugins->Cron)):
          foreach($plugins->Auth as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (Cron Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Cron</td>
  </tr>
 
        <?php
          }
 
      endif;
 
 
      if (isset($plugins->Logging)):
          foreach($plugins->Logging as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (Logging Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Logging</td>
  </tr>
 
        <?php
          }
 
      endif;
 
    if (isset($plugins->Customers)):
  foreach($plugins->Customers as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (<?php echo Lang::_('Customers');?> Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Customers</td>
  </tr>
 
        <?php
          }
 
    endif;
 
    if (isset($plugins->Creds)):
  foreach($plugins->Creds as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (<?php echo Lang::_('Credentials');?> Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Creds</td>
  </tr>
 
        <?php
          }
 
 
      endif;
 
 
    if (isset($plugins->CredTypes)):
  foreach($plugins->CredTypes as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (<?php echo Lang::_('Credential Type');?> Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=CredTypes</td>
  </tr>
 
        <?php
          }
 
 
      endif;
 
 
 
 if (isset($plugins->Resources)):
  foreach($plugins->Resources as $plugin=>$status){
          ?>
 
  <tr>
    <td><?php echo $plugin; ?> (Resources Plugin)</td>
    <td>Plugin:</td>
    <td><?php echo $plugin; ?></td>
    <td></td>
    <td>plg</td>
    <td>plgInfo</td>
    <td>type=Resources</td>
  </tr>
 
        <?php
          }
 
 
      endif;
 
  endif;?>
 
 
  <tr>
    <td>Log Out</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td>logout</td>
  </tr>
 
  <tr>
    <td>Change Password</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td>changePassword</td>
  </tr>
 
 
</table>
 
 
          <!-- Search Table Ends --->
<?php endif;?>