default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / view / logo.cgi
1 <% $data %>
2 <%init>
3
4 die "access denied"
5   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
6
7 my $conf = new FS::Conf;
8
9 my $type;
10 if ( $cgi->param('type') eq 'png' ) {
11   $type = 'png';
12 } elsif ( $cgi->param('type') eq 'eps' ) {
13   $type = 'eps';
14 } else {
15   die "unknown logo type ". $cgi->param('type');
16 }
17
18 my $data;
19 if ( $cgi->param('preview_session') =~ /^(\w+)$/ ) {
20
21   my $session = $1;
22   my $curuser = $FS::CurrentUser::CurrentUser;
23   $data = decode_base64( $curuser->option("logo_preview$session") );
24
25 } elsif ( $cgi->param('name') =~ /^([^\.\/]*)$/ ) {
26
27   my $templatename = $1;
28   if ( $templatename && $conf->exists("logo_$templatename.$type") ) {
29     $templatename = "_$templatename";
30   } else {
31     $templatename = '';
32   }
33
34   if ( $type eq 'png' ) {
35     $data = $conf->config_binary("logo$templatename.png");
36   } elsif ( $type eq 'eps' ) {
37     #convert EPS to a png... punting on that for now
38   }
39
40 } else {
41   die "neither a valid name nor a valid preview_session specified";
42 }
43
44 http_header('Content-Type' => 'image/png' );
45
46 </%init>
47