edit_uflags.pl
801 lines of code
1
#!/usr/local/bin/perl
2
3
($<,$>) = (getpwnam('nobody'), getpwnam('nobody')) or die $!;
4
5
binmode(STDIN, ":utf8");
6
binmode(STDOUT, ":utf8");
7
8
# must have's!
9
use strict;
10
use warnings;
11
use CGI::Carp qw(fatalsToBrowser);
12
use DBI;
13
use URI::Escape;
14
15
use lib "/var/www/html/Pm";
16
17
use Date qw(
18
            expand_date
19
            get_today
20
           );
21
use Html qw(
22
            pre_html_header
23
            header
24
            html_end
25
            img
26
            div
27
           );
28
use Html2 qw(
29
             tag
30
             br
31
             hr
32
             embolden
33
             italicize
34
             small
35
            );
36
use Bc_chef qw(cookie_get cookie_delete);
37
use Bc_misc qw(
38
               get_param
39
               referrer
40
               get_params_asHash
41
               pluralize
42
               word_as_possessive
43
              );
44
use Bc_sql qw(
45
              get_constant
46
              get_flag_data
47
              get_security_asWord_friendly
48
              sql_execute
49
              user_exists
50
              $QUERY_PAGE
51
              $QUERY_UID
52
              $LOGGEDIN
53
54
              $DB
55
             );
56
57
use Security qw(banned);
58
use Redir qw(error_redir notice_redir);
59
use User qw(
60
            get_user_pics
61
            isUserAdmin
62
            isUserModerator
63
            get_user_flag_count
64
            get_user_stat
65
            get_uid_byNickname
66
           );
67
68
my %params = get_params_asHash();
69
70
my $DEBUG = 0;
71
72
my $output;
73
74
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserModerator($LOGGEDIN)) {
75
  my $msg =  "Access Denied";
76
  if ($DEBUG) { $msg .= " (edit_uflags.pl)"; }
77
  $output = error_redir("/", $msg);
78
} # end if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserModerator($LOGGEDIN))
79
else {
80
  if (not user_exists($params{$QUERY_UID})) {
81
    # then maybe we were given a nickname?
82
    $params{$QUERY_UID} = get_uid_byNickname($params{$QUERY_UID});
83
    if (not user_exists($params{$QUERY_UID})) {
84
      print pre_html_header();
85
      print "no such uid: $params{$QUERY_UID}";
86
      exit 1;
87
    }
88
  }
89
  ############################################################
90
  ### YOUR CONTENT HERE
91
  my $flags = get_user_flag_count($params{$QUERY_UID}, "all", "d", $params{sh});
92
93
  $output = pre_html_header({type=>"text/html"});
94
  $output .= header(
95
                    "User Flags Manager",
96
                    "?nobg_img=1&nogrid=1",
97
                    "",
98
                    "setTimeout(removeMsg, " . get_constant("REMOVE_MSG_TIMEOUT") . ");",
99
                    "",
100
                    "style='display: flex; height: min-content;'"
101
                   );
102
103
  { my %container;
104
    $container{tag} = "div";
105
    #$container{class} = "bordered";
106
    $container{style} = "margin: 0 0; width: 100%;";
107
    $container{innerHTML} = "";
108
109
    if ($DEBUG) {
110
      my %debug;
111
      $debug{tag} = "div";
112
      $debug{class} = "subnavbar";
113
      $debug{style} = "width: 100%;";
114
      $debug{innerHTML} = "<table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td class=nowrap width=1>" .
115
                          "DEBUGGING USER FLAGS MANAGER" .
116
                          "</td><td class=spacerx></td><td align=right>";
117
      { my %button;
118
        $button{tag} = "button";
119
        $button{type} = "button";
120
        $button{name} = "sh";
121
        $button{value} = $params{sh};
122
        $button{class} = "yellow";
123
        $button{onclick} = "document.location.reload();";
124
        $button{innerHTML} = "Reload";
125
126
        $debug{innerHTML} .= tag(\%button);
127
      } # end button
128
129
      $debug{innerHTML} .= "</td></tr></table>";
130
131
      $container{innerHTML} .= tag(\%debug);
132
    } # end if $DEBUG
133
134
    my $url = "/edit_uflags.pl?$QUERY_UID=$params{$QUERY_UID}";
135
    if ($params{$QUERY_UID}) {
136
      my $hidden = 0;
137
      if (not $params{sh}) {
138
        my $ncount = get_user_flag_count($params{$QUERY_UID}, "all", "c", 0);
139
        my $fcount = get_user_flag_count($params{$QUERY_UID}, "all", "c", 1);
140
        $hidden = $fcount - $ncount;
141
      } # if not $params{sh}
142
143
      if ($params{save_status} eq 1) {
144
        my $redir = "./edit_uflags.pl?$QUERY_UID=$params{$QUERY_UID}";
145
        if ($params{sh}) { $redir .= "&sh=1"; }
146
        if ($DEBUG) {
147
          my %debug;
148
          $debug{tag} = "div";
149
          $debug{class} = "translucent";
150
          $debug{innerHTML} = "id: " . embolden($params{get_constant("FLAG_ID")}) . br .
151
                     "status: " . embolden($params{status}) . br .
152
                     "redir: " . embolden($redir) . br .
153
                     "flag count: " . embolden($flags) . br;
154
155
          $container{innerHTML} .= tag(\%debug);
156
        } # if $DEBUG
157
158
        my $flag_data = get_flag_data($params{get_constant("FLAG_ID")});
159
160
        if ($flag_data) {
161
          # if moderator_notes has a value, append ";"
162
          # append to moderator_notes: $LOGGEDIN=set status to $params{status}, get_today("db")
163
          # change status
164
          # change moderator_ID
165
          my $note = "";
166
          if ($flag_data->{moderator_notes}) { $note = $flag_data->{moderator_notes} . ";"; }
167
          $note .= $LOGGEDIN . "=set status to $params{status}, " . expand_date(get_today("db"));
168
169
          my $sql = "update flagged set";
170
          $sql .= " status=" . $DB->quote($params{status});
171
          $sql .= ", moderator_ID=" . $DB->quote($params{muid});
172
          $sql .= ", moderator_notes=" . $DB->quote($note);
173
          $sql .= " where ID=" . $DB->quote($params{get_constant("FLAG_ID")});
174
175
          if ($DEBUG) {
176
            $container{innerHTML} .= "sql: " . embolden($sql) . br;
177
          } else {
178
            # actually post the change
179
            if (sql_execute($sql, "edit_uflags.pl - change status")) {
180
              print notice_redir($redir, "Done!");
181
            } else {
182
              print error_redir($redir, "Error!");
183
            }
184
185
            exit 1;
186
          }
187
        } # end if $flag_data
188
        else {
189
          if ($DEBUG) {
190
            $container{innerHTML} .= "no such flag id: " . embolden($params{get_constant("FLAG_ID")});
191
          } else {
192
            print error_redir($url, "No Such Flag ID: " . embolden($params{get_constant("FLAG_ID")}));
193
            exit;
194
          }
195
        } # end else of if $flag_data
196
      } # end if $params{save_status} eq 1
197
      elsif ($params{d} eq 1) {
198
        # delete an entry
199
        { my %container;
200
          my $flag = get_flag_data($params{get_constant("FLAG_ID")});
201
202
          $container{tag} = "div";
203
          $container{class} = "bordered fullsize centered";
204
          $container{innerHTML} = "";
205
206
          if ($flag) {
207
            if (get_param("c") == 1) {
208
              my $sql = "delete from flagged where ID=" . $DB->quote($flag->{ID});
209
              if (sql_execute($sql, "/edit_uflags.pl->delete flag")) {
210
                print notice_redir($url, "Entry Deleted");
211
              } else {
212
                print error_redir($url, "Delete Entry Failed");
213
              }
214
              exit 1;
215
            } # end if get_param("c") == 1)
216
            else {
217
              { my %query;
218
                $query{tag} = "div";
219
                $query{class} = "blue-panel center";
220
                $query{innerHTML} = "";
221
222
                $query{innerHTML} .= "Delete Flagged Item Entry" . br .
223
                                      "Given Flag ID: " . embolden($params{get_constant("FLAG_ID")}) . br . br;
224
225
                { my %form;
226
                  $form{tag} = "form";
227
                  $form{class} = "bordered";
228
                  $form{method} = "get";
229
                  $form{action} = "/edit_uflags.pl";
230
                  $form{innerHTML} = "";
231
232
                  { my %input;
233
                    $input{tag} = "input";
234
                    $input{type} = "hidden";
235
                    $input{name} = $QUERY_UID;
236
                    $input{value} = $flag->{UID};
237
238
                    $form{innerHTML} .= tag(\%input);
239
                  } # end hidden flag id input
240
241
                  { my %input;
242
                    $input{tag} = "input";
243
                    $input{type} = "hidden";
244
                    $input{name} = get_constant("FLAG_ID");
245
                    $input{value} = $flag->{ID};
246
247
                    $form{innerHTML} .= tag(\%input);
248
                  } # end hidden flag id input
249
250
                  { my %input;
251
                    $input{tag} = "input";
252
                    $input{type} = "hidden";
253
                    $input{name} = "d";
254
                    $input{value} = 1;
255
256
                    $form{innerHTML} .= tag(\%input);
257
                  } # end hidden delete entry input
258
259
                  { my %cinput;
260
                    $cinput{tag} = "input";
261
                    $cinput{type} = "hidden";
262
                    $cinput{name} = "c";
263
                    $cinput{value} = 1;
264
265
                    $form{innerHTML} .= tag(\%cinput);
266
                  } # end hidden delete entry input
267
268
                  { my %button;
269
                    $button{tag} = "button";
270
                    $button{type} = "submit";
271
                    $button{class} = "green padded";
272
                    $button{name} = "c";
273
                    $button{value} = 1;
274
                    $button{innerHTML} = "Proceed";
275
                    $button{onclick} = "submit();";
276
277
                    $form{innerHTML} .= tag(\%button);
278
                  } # end proceed button
279
280
                  $form{innerHTML} .= "   ";
281
282
                  { my %button;
283
                    $button{tag} = "button";
284
                    $button{type} = "button";
285
                    $button{class} = "red padded";
286
                    $button{innerHTML} = "Cancel";
287
                    $button{onclick} = "previous_page();";
288
289
                    $form{innerHTML} .= tag(\%button);
290
                  } # end cancel button
291
292
                  $query{innerHTML} .= tag(\%form);
293
                } # end of query div
294
295
                $container{innerHTML} .= tag(\%query);
296
              } # end of container div
297
            } # end else of if get_param("c") eq 1
298
          } # end if $flag
299
          else {
300
            print error_redir($url, "Can't Delete a Non-Existent Entry!");
301
            exit 1;
302
          } # end else of if $flag
303
304
          $container{innerHTML} .= tag(\%container);
305
        } # end container
306
      } # end if $params{d} eq 1
307
      else {
308
        # show the manager
309
        if ($DEBUG) {
310
          my %debug;
311
          $debug{tag} = "div";
312
          $debug{class} = "translucent";
313
          $debug{innerHTML} = "uid: " . embolden($params{$QUERY_UID}) . br .
314
                              "flag count: " . embolden((@$flags)) . br .
315
                              "sh: " . embolden($params{sh}) . br;
316
          if ($hidden) { $debug{innerHTML} .= "hidden count: " . embolden($hidden) . br; }
317
318
          $container{innerHTML} .= tag(\%debug);
319
        }
320
321
        { my %titlebar;
322
          $titlebar{tag} = "div";
323
          $titlebar{class} = "subnavbar sticky";
324
          $titlebar{style} = "width: 100%; text-align: left;";
325
          $titlebar{innerHTML} = "<table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td width=1>";
326
327
          { my %reload; # reload button
328
            $reload{tag} = "button";
329
            $reload{type} = "button";
330
            $reload{name} = "sh";
331
            $reload{value} = $params{sh};
332
            $reload{class} = "yellow";
333
            $reload{onclick} = "document.location.reload();";
334
            $reload{title} = "Reload Flags Manager";
335
336
            { my %img;
337
              $img{tag} = "img";
338
              $img{src} = "/img.pl?i=site/reload.png&s=u";
339
340
              $reload{innerHTML} = tag(\%img);
341
            }
342
343
            $titlebar{innerHTML} .= tag(\%reload);
344
          } # end reload button
345
346
          $titlebar{innerHTML} .= "</td><td class=spacerx></td><td class='nowrap subtitle text-align-left'>Flags Manager";
347
348
          my $e = cookie_get("e");
349
          my $n = cookie_get("n");
350
          if ($e or $n) {
351
            $titlebar{innerHTML} .= "</td><td class=spacerx></td><td align=center>";
352
            my $class = "small error";
353
            my $msg = $e;
354
            if ($n) { $class = "small notice"; $msg = $n; }
355
            { my %msg;
356
              $msg{tag} = "div";
357
              $msg{id} = "MSGS";
358
              $msg{class} = "inline $class";
359
              $msg{innerHTML} = $msg;
360
361
              $titlebar{innerHTML} .= tag(\%msg);
362
            }
363
          }
364
          $titlebar{innerHTML} .= "</td><td class=spacerx></td><td align=right class=nowrap width=1>";
365
366
          { my %hideflags; # show/hide all flags button
367
            $hideflags{tag} = "button";
368
            $hideflags{type} = "button";
369
            $hideflags{class} = "yellow";
370
371
            my %img;
372
            $img{tag} = "img";
373
374
            if ($params{sh} eq 1) {
375
              $hideflags{title} = "Hide Invalid and Deleted Flags";
376
              $hideflags{onclick} = "document.location.href=\"?$QUERY_UID=$params{$QUERY_UID}\";";
377
              $img{src} = "/img.pl?i=site/read.png&s=u";
378
            } else {
379
              $hideflags{title} = "Show Invalid and Deleted Flags";
380
              $hideflags{onclick} = "document.location.href=\"?sh=1&$QUERY_UID=$params{$QUERY_UID}\";";
381
              $img{src} = "/img.pl?i=site/eye_close.png&s=u";
382
            }
383
384
            $hideflags{innerHTML} = tag(\%img);
385
            $titlebar{innerHTML} .= tag(\%hideflags);
386
          } # end show/hide all flags button
387
388
          $titlebar{innerHTML} .= "</td></tr></table>";
389
390
          $container{innerHTML} .= tag(\%titlebar);
391
        } # end titlebar div
392
393
        ##################################################################################
394
        { my %div; # some div
395
          $div{tag} = "div";
396
          $div{class} = "translucent";
397
          $div{style} = "min-height: 320px;";
398
          $div{innerHTML} = "<table border=0 cellpadding=0 cellspacing=0 width=100%><tr>";
399
400
          if (ref $flags eq "ARRAY") {
401
            if (@$flags) {
402
              $div{innerHTML} .= "<td align=center class=subtitle>";
403
              $div{innerHTML} .= (@$flags) . " " . pluralize("item", @$flags) . " flagged";
404
              if (not $params{sh} and $hidden) { $div{innerHTML} .= small("(" . embolden($hidden) . " hidden)"); }
405
              $div{innerHTML} .= "</td></tr><tr><td class=spacery_large>";
406
              $div{innerHTML} .= "</td></tr><tr><td align=center>";
407
              my $hr = 0;
408
              foreach my $flag (@$flags) {
409
                if ($hr) { $div{innerHTML} .= hr; }
410
                $hr++;
411
                my $showflag = 1;
412
                if (($flag->{status} eq "trashed" or $flag->{status} eq "invalid") and not $params{sh}) { $showflag = 0; }
413
414
                if ($showflag) {
415
                  { my %script;
416
                    $script{tag} = "script";
417
                    $script{innerHTML} = "\n" .
418
                                         "function chClr(e) {\n" .
419
                                         "  if (e) {\n" .
420
                                         "    e.style.backgroundColor = e.options[e.selectedIndex].style.backgroundColor;\n" .
421
                                         "    e.style.color = e.options[e.selectedIndex].style.color;\n" .
422
                                         "  }\n" .
423
                                         "}\n" .
424
                                         "\n" .
425
                                         "function submitChanges(form) {\n" .
426
                                         "  if (form) {\n" .
427
                                         "    return form.submit();\n" .
428
                                         "  }\n" .
429
                                         "}\n";
430
431
                    $div{innerHTML} .= tag(\%script);
432
                  } # end script
433
434
                  { my %flagcontainer;
435
                    $flagcontainer{tag} = "div";
436
                    $flagcontainer{class} = "translucent-fadein";
437
                    $flagcontainer{innerHTML} = "";
438
439
                    $flagcontainer{innerHTML} .= "<table border=0 cellpadding=0 cellspacing=0><tr><td>";
440
                    { my %flaglabel;
441
                      $flaglabel{tag} = "div";
442
                      $flaglabel{class} = "subnavbar_dark";
443
                      $flaglabel{innerHTML} = "ID";
444
445
                      $flagcontainer{innerHTML} .= tag(\%flaglabel);
446
                    } # end flag label
447
                    $flagcontainer{innerHTML} .= "</td><td class=spacerx></td><td>";
448
                    { my %flagid;
449
                      $flagid{tag} = "div";
450
                      $flagid{class} = "subnavbar_dark";
451
                      $flagid{innerHTML} = $flag->{ID};
452
453
                      $flagcontainer{innerHTML} .= tag(\%flagid);
454
                    } # end flag id
455
                    $flagcontainer{innerHTML} .= "</td><td class=spacerx></td><td align=center>";
456
                    { my %dof;
457
                      $dof{tag} = "div";
458
                      $dof{class} = "subnavbar_dark nowrap";
459
                      $dof{innerHTML} = expand_date($flag->{DOF});
460
461
                      $flagcontainer{innerHTML} .= tag(\%dof);
462
                    } # end date of flag
463
                    $flagcontainer{innerHTML} .= "</td><td class=spacerx></td><td align=center>";
464
465
                    my $sClr = "blue";
466
                    if ($flag->{status} eq "pending") { $sClr = "blue"; }
467
                    elsif ($flag->{status} eq "elevated") { $sClr = "orange"; }
468
                    elsif ($flag->{status} eq "msg1") { $sClr = "green"; }
469
                    elsif ($flag->{status} eq "msg2") { $sClr = "yellow"; }
470
                    elsif ($flag->{status} eq "msg3") { $sClr = "red"; }
471
                    elsif ($flag->{status} eq "invalid") { $sClr = "brown"; }
472
                    elsif ($flag->{status} eq "rectified") { $sClr = "grey"; }
473
                    elsif ($flag->{status} eq "trashed") { $sClr = "black"; }
474
475
                    { my %form;
476
                      $form{tag} = "form";
477
                      $form{method} = "get";
478
                      $form{action} = "/edit_uflags.pl";
479
                      $form{class} = "inline nowrap";
480
                      $form{id} = "statusForm$flag->{ID}";
481
                      $form{onchange} = "submitChanges(document.getElementById(\"statusForm$flag->{ID}\"));";
482
                      $form{innerHTML} = "";
483
484
                      { my %input;
485
                        $input{tag} = "input";
486
                        $input{type} = "hidden";
487
                        $input{name} = "muid";
488
                        $input{value} = $LOGGEDIN;
489
490
                        $form{innerHTML} .= tag(\%input);
491
                      } # hidden muid
492
493
                      { my %input;
494
                        $input{tag} = "input";
495
                        $input{type} = "hidden";
496
                        $input{name} = "sh";
497
                        $input{value} = $params{sh};
498
499
                        $form{innerHTML} .= tag(\%input);
500
                      }
501
502
                      { my %input;
503
                        $input{tag} = "input";
504
                        $input{type} = "hidden";
505
                        $input{name} = "save_status";
506
                        $input{value} = "1";
507
508
                        $form{innerHTML} .= tag(\%input);
509
                      }
510
511
                      { my %input;
512
                        $input{tag} = "input";
513
                        $input{type} = "hidden";
514
                        $input{name} = get_constant("FLAG_ID");
515
                        $input{value} = $flag->{ID};
516
517
                        $form{innerHTML} .= tag(\%input);
518
                      }
519
520
                      { my %input;
521
                        $input{tag} = "input";
522
                        $input{type} = "hidden";
523
                        $input{name} = $QUERY_UID;
524
                        $input{value} = $flag->{UID};
525
526
                        $form{innerHTML} .= tag(\%input);
527
                      }
528
529
                      { my %select;
530
                        $select{tag} = "select";
531
                        $select{class} = "small";
532
                        $select{id} = "statusdd" . $flag->{ID};
533
                        $select{name} = "status";
534
                        $select{onchange} = "chClr(\"statusdd" . $flag->{ID} . "\");";
535
                        $select{style} = "background-color: $sClr; color: white; width: 60px;";
536
                        $select{innerHTML} = "";
537
538
                        { my %pending;
539
                          $pending{tag} = "option";
540
                          $pending{style} = "background-color: blue; color: white;";
541
                          $pending{value} = "pending";
542
                          if ($flag->{status} eq "pending") { $pending{selected} = 1; }
543
                          $pending{innerHTML} = "Pending";
544
545
                          $select{innerHTML} .= tag(\%pending);
546
                        } # end pending
547
548
                        { my %elevated;
549
                          $elevated{tag} = "option";
550
                          $elevated{style} = "background-color: orange;";
551
                          $elevated{value} = "elevated";
552
                          if ($flag->{status} eq "elevated") { $elevated{selected} = 1; }
553
                          $elevated{innerHTML} = "Elevated";
554
555
                          $select{innerHTML} .= tag(\%elevated);
556
                        } # end elevated
557
558
                        { my %msg1;
559
                          $msg1{tag} = "option";
560
                          $msg1{style} = "background-color: #888800;";
561
                          $msg1{value} = "msg1";
562
                          if ($flag->{status} eq "msg1") { $msg1{selected} = 1; }
563
                          $msg1{innerHTML} = "Msg 1";
564
565
                          $select{innerHTML} .= tag(\%msg1);
566
                        } # end msg1
567
568
                        { my %msg2;
569
                          $msg2{tag} = "option";
570
                          $msg2{style} = "background-color: #880000; color: white;";
571
                          $msg2{value} = "msg2";
572
                          if ($flag->{status} eq "msg2") { $msg2{selected} = 1; }
573
                          $msg2{innerHTML} = "Msg 2";
574
575
                          $select{innerHTML} .= tag(\%msg2);
576
                        } # end msg2
577
578
                        { my %msg3;
579
                          $msg3{tag} = "option";
580
                          $msg3{style} = "background-color: #ff0000; color: white;";
581
                          $msg3{value} = "msg3";
582
                          if ($flag->{status} eq "msg3") { $msg3{selected} = 1; }
583
                          $msg3{innerHTML} = "Msg 3";
584
585
                          $select{innerHTML} .= tag(\%msg3);
586
                        } # end msg3
587
588
                        { my %invalid;
589
                          $invalid{tag} = "option";
590
                          $invalid{style} = "background-color: brown; color: white;";
591
                          $invalid{value} = "invalid";
592
                          if ($flag->{status} eq "invalid") { $invalid{selected} = 1; }
593
                          $invalid{innerHTML} = "Invalid";
594
595
                          $select{innerHTML} .= tag(\%invalid);
596
                        } # end invalid
597
598
                        { my %rectified;
599
                          $rectified{tag} = "option";
600
                          $rectified{style} = "background-color: green; color: white;";
601
                          $rectified{value} = "rectified";
602
                          if ($flag->{status} eq "rectified") { $rectified{selected} = 1; }
603
                          $rectified{innerHTML} = "Rectified";
604
605
                          $select{innerHTML} .= tag(\%rectified);
606
                        } # end rectified
607
608
                        { my %trashed;
609
                          $trashed{tag} = "option";
610
                          $trashed{style} = "background-color: black; color: white;";
611
                          $trashed{value} = "trashed";
612
                          if ($flag->{status} eq "trashed") { $trashed{selected} = 1; }
613
                          $trashed{innerHTML} = "Trashed";
614
615
                          $select{innerHTML} .= tag(\%trashed);
616
                        } # end trashed
617
618
                        $form{innerHTML} .= tag(\%select);
619
                      } # end select
620
621
                      { my %script;
622
                        $script{tag} = "script";
623
                        $script{innerHTML} = "chClr(statusdd" . $flag->{ID} . ");";
624
625
                        $form{innerHMTL} .= tag(\%script);
626
                      } # end script
627
628
                      $flagcontainer{innerHTML} .= tag(\%form);
629
                    } # end form
630
631
                    $flagcontainer{innerHTML} .= "</td><td class=spacerx rowspan=10></td><td align=right rowspan=10 width=1 valign=top>";
632
                    if (isUserAdmin()) {
633
                      my %button;
634
                      $button{tag} = "button";
635
                      $button{type} = "button";
636
                      $button{class} = "red padded";
637
                      $button{onclick} = "document.location=\"/edit_uflags.pl?" . get_constant("FLAG_ID") . "=" . $flag->{ID} . "&$QUERY_UID=$flag->{UID}&d=1\";";
638
                      $button{title} = "Delete Flag";
639
                      $button{innerHTML} = "X";
640
641
                      $flagcontainer{innerHTML} .= tag(\%button);
642
                      $flagcontainer{innerHTML} .= br;
643
                    } # end if user is admin
644
645
                    { my %button;
646
                      $button{tag} = "button";
647
                      $button{type} = "button";
648
                      $button{class} = "yellow";
649
                      $button{onclick} = "document.location.href='./edit_uflags.pl?$QUERY_UID=$params{$QUERY_UID}&msg=1';";
650
                      $button{title} = "Send Internal Messaage";
651
652
                      { my %img;
653
                        $img{tag} = "img";
654
                        $img{class} = "margins-top-bottom";
655
                        $img{src} = "/img.pl?i=site/compose.png&s=u";
656
657
                        $button{innerHTML} = tag(\%img);
658
                      }
659
660
                      $flagcontainer{innerHTML} .= tag(\%button);
661
                      $flagcontainer{innerHTML} .= br;
662
                    } # end send msg button
663
664
                    { my %button;
665
                      $button{tag} = "button";
666
                      $button{type} = "button";
667
                      $button{class} = "blue";
668
                      $button{onclick} = "document.location.href='./sendemail.pl?$QUERY_UID=$params{$QUERY_UID}';";
669
                      $button{title} = "Send Email";
670
671
                      { my %img;
672
                        $img{tag} = "img";
673
                        $img{class} = "margins-top-bottom";
674
                        $img{src} = "/img.pl?i=site/msg.png&s=u";
675
676
                        $button{innerHTML} = tag(\%img);
677
                      }
678
679
                      $flagcontainer{innerHTML} .= tag(\%button);
680
                      $flagcontainer{innerHTML} .= br;
681
                    } # end send email button
682
683
                    $flagcontainer{innerHTML} .= "</td></tr><tr><td class=spacery_large colspan=7>";
684
                    $flagcontainer{innerHTML} .= "</td></tr><tr><td colspan=7>";
685
686
                    $flagcontainer{innerHTML} .= embolden(get_user_stat($flag->{flagger_ID}, "nickname"));
687
                    $flagcontainer{innerHTML} .= " flagged ";
688
                    $flagcontainer{innerHTML} .= embolden(word_as_possessive(get_user_stat($flag->{UID}, "nickname"))) . " ";
689
                    if ($flag->{type} eq "d") { $flagcontainer{innerHTML} .= "description:"; }
690
                    elsif ($flag->{type} eq "i") { $flagcontainer{innerHTML} .= "image:"; }
691
                    elsif ($flag->{type} eq "n") { $flagcontainer{innerHTML} .= "nickname"; }
692
                    elsif ($flag->{type} eq "m") { $flagcontainer{innerHTML} .= "message:"; }
693
                    else { $flagcontainer{innerHTML} .= embolden("(unknown)"); }
694
695
                    $flagcontainer{innerHTML} .= "</td></tr><tr><td class=spacery_large colspan=7>";
696
                    $flagcontainer{innerHTML} .= "</td></tr><tr><td colspan=7 align=center>";
697
698
                    if ($flag->{type} eq "d") {
699
                      my %desc;
700
                      $desc{tag} = "div";
701
                      $desc{class} = "sunken scrolling_vertical text-align-left";
702
                      $desc{style} = "min-height: 50px; max-height: 50px; height: 50px; margin-bottom: 5px;";
703
                      $desc{innerHTML} = get_user_stat($flag->{UID}, "description");
704
705
                      $flagcontainer{innerHTML} .= tag(\%desc);
706
                    } elsif ($flag->{type} eq "i") {
707
                      my %img;
708
                      $img{tag} = "img";
709
                      $img{class} = "rounded bordered";
710
                      $img{style} = "margin-bottom: 5px;";
711
                      $img{src} = "/getimage.pl?id=$flag->{content_ID}&th=1";
712
713
                      $flagcontainer{innerHTML} .= tag(\%img);
714
                    } elsif ($flag->{type} eq "m") {
715
                      my %msg;
716
                      $msg{tag} = "div";
717
                      $msg{class} = "sunken scrolling_vertical";
718
                      $msg{style} = "min-height: 50px; max-height: 50px; height: 50px; margin-bottom: 5px;";
719
                      $msg{innerHTML} = get_user_message($flag->{content_ID});
720
721
                      $flagcontainer{innerHTML} .= tag(\%msg);
722
                    } else {
723
                      $flagcontainer{innerHTML} .= br;
724
                    }
725
726
                    $flagcontainer{innerHTML} .= tag({tag=>"div", class=>"yellow-panel small", innerHTML=>"because " . $flag->{flagger_reason}});
727
728
                    if ($flag->{moderator_ID}) {
729
                      $flagcontainer{innerHTML} .= "</td></tr><tr><td class=spacery_large colspan=7>";
730
                      $flagcontainer{innerHTML} .= "</td></tr><tr><td colspan=9>";
731
                      $flagcontainer{innerHTML} .= "Last Modified by " . embolden(get_security_asWord_friendly(get_user_stat($flag->{moderator_ID}, "security"))) . ", " . italicize(get_user_stat($flag->{moderator_ID}, "nickname"));
732
                      if ($flag->{moderator_notes}) {
733
                        $flagcontainer{innerHTML} .= "</td></tr><tr><td class=spacery_large colspan=7>";
734
                        $flagcontainer{innerHTML} .= "</td></tr><tr><td colspan=9>";
735
                        { my %modnotes;
736
                          $modnotes{tag} = "div";
737
                          $modnotes{class} = "subnavbar scrolling_vertical";
738
                          $modnotes{style} = "text-align: left; max-height: 80px;";
739
                          $modnotes{innerHTML} = $flag->{moderator_notes};
740
741
                          $flagcontainer{innerHTML} .= tag(\%modnotes);
742
                        } # end modnotes div
743
                      } # end if $flag->{moderator_notes}
744
                    } # end if $flag->{moderator_ID}
745
                    $flagcontainer{innerHTML} .= "</td></tr></table>";
746
747
                    $div{innerHTML} .= tag(\%flagcontainer);
748
                  } # end flag container div
749
                } # if ($showflag)
750
              } # end foreach flag
751
            } # end if (@$flags)
752
            else {
753
              $div{innerHTML} .= "<td align=center height=270>";
754
              { my %none;
755
                $none{tag} = "div";
756
                $none{class} = "yellow-panel";
757
                $none{innerHTML} = italicize("No Flags Found!");
758
759
                $div{innerHTML} .= tag(\%none);
760
              }
761
762
              if ($hidden) { $div{innerHTML} .= br . small("(well, " . embolden($hidden) . pluralize("is", $hidden) . " hidden)"); }
763
            } # end else of if (@$flags)
764
          } # end if ref $flag eq array
765
          else {
766
            $div{innerHTML} .= "<td align=center height=270>";
767
            $div{innerHTML} .= $params{$QUERY_UID} . br;
768
            $div{innerHTML} .= "Major Glitch!";
769
          } # end else of if ref $flag eq array
770
          $div{innerHTML} .= "</td></tr></table>";
771
772
          $container{innerHTML} .= tag(\%div);;
773
        } # end some div
774
      } # end else of elsif ($params{d} eq 1)
775
    } # end if $params{$QUERY_UID}
776
    else {
777
      if ($DEBUG) {
778
        $container{innerHTML} .= "Provide a UID!" . br;
779
        foreach my $key (keys %params) {
780
          $container{innerHTML} .= $key . "=" . $params{$key} . br;
781
        }
782
      } # end if $DEBUG
783
      else {
784
        print error_redir($url, "Provide a UID, please...");
785
        exit 1;
786
      } # end else of if $DEBUG
787
    } # end else of if $params{$QUERY_UID}
788
789
    $output .= tag(\%container);
790
  } # end container div
791
792
  ### END YOUR CONTENT
793
  $output .= html_end();
794
  ############################################################
795
} # end else of if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserModerator($LOGGEDIN))
796
797
print cookie_delete("e");
798
print cookie_delete("n");
799
print $output;
800
801
exit 1;