summaryrefslogtreecommitdiff
path: root/httemplate/view/logo.cgi
blob: aeca0f3b3b68d7c8f1c06955e6f15fbd55303289 (plain)
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
<% $data %>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $conf = new FS::Conf;

my $type;
if ( $cgi->param('type') eq 'png' ) {
  $type = 'png';
} elsif ( $cgi->param('type') eq 'eps' ) {
  $type = 'eps';
} else {
  die "unknown logo type ". $cgi->param('type');
}

my $data;
if ( $cgi->param('preview_session') =~ /^(\w+)$/ ) {

  my $session = $1;
  my $curuser = $FS::CurrentUser::CurrentUser;
  $data = decode_base64( $curuser->option("logo_preview$session") );

} elsif ( $cgi->param('name') =~ /^([^\.\/]*)$/ ) {

  my $templatename = $1;
  if ( $templatename && $conf->exists("logo_$templatename.$type") ) {
    $templatename = "_$templatename";
  } else {
    $templatename = '';
  }

  if ( $type eq 'png' ) {
    $data = $conf->config_binary("logo$templatename.png");
  } elsif ( $type eq 'eps' ) {
    #convert EPS to a png... punting on that for now
  }

} else {
  die "neither a valid name nor a valid preview_session specified";
}

http_header('Content-Type' => 'image/png' );

</%init>