getdpid.pl
66 lines of code
1
#!/usr/local/bin/perl
2
3
binmode(STDIN, ":utf8");
4
binmode(STDOUT, ":utf8");
5
6
# must have's!
7
use strict;
8
use warnings;
9
use CGI::Carp qw(fatalsToBrowser);
10
use DBI;
11
use URI::Escape;
12
13
use lib "/var/www/html/Pm";
14
15
use Html qw(pre_html_header header);
16
use Bc_chef qw(cookie_get);
17
use Bc_misc qw(get_param referrer);
18
use Bc_sql qw(sql_execute
19
              get_constant
20
              user_exists
21
              $QUERY_PAGE
22
              $QUERY_UID
23
              $LOGGEDIN
24
25
              $DB
26
             );
27
use Redir qw(notice_redir error_redir);
28
use User qw(isUserAdmin $USER_DATA get_user_dpID get_user_stat);
29
use Security qw(banned);
30
31
my $DEBUG = 0;
32
33
my $output;
34
35
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserAdmin($LOGGEDIN)) {
36
  my $msg =  "Access Denied";
37
  if ($DEBUG) { $msg .= " (TEMPLATE_ADMIN.pl)"; }
38
  $output = error_redir("/", $msg);
39
} else {
40
  ############################################################
41
42
  ### YOUR CONTENT HERE
43
  $output = pre_html_header({type=>'text/plain'}, 1);
44
45
  my $uid = get_param($QUERY_UID);
46
  my $dpid = get_user_dpID($uid);
47
  if (not $dpid) {
48
    if (get_user_stat($uid, "gender") eq 1)
49
      { $dpid = 1; } else
50
      { $dpid = 2; }
51
  }
52
53
  if ($DEBUG) {
54
    $output .= "getdpid.pl\n";
55
    $output .= "uid: $uid\n";
56
    $output .= "dpid: $dpid\n";
57
  } else {
58
    $output .= $dpid;
59
  }
60
61
  ############################################################
62
}
63
64
print $output;
65
66
exit 1;