### Receives a skin from the DiscusWare skin gallery
###
sub appear_receive_direct_upload {
my ($FORMref, $result) = @_;
$FORMref->{skin} = $` if $FORMref->{skin} =~ /\.tmpl\s*$/;
error_message("Invalid Skin Name", "Skin name is invalid! It may contain only alphanumeric characters and '-'.", 0, 1) if $FORMref->{skin} !~ /^[\w\-]+$/;
my $content = unescape($FORMref->{content});
if (length $content != $FORMref->{slength}) {
my $len = length $content;
template_error("Uploaded skin had the wrong size (received size: $len; expected size: $FORMref->{slength})! Try uploading again.", 0, 1);
}
if (unpack("%16C*", $content) != $FORMref->{checksum}) {
template_error("Uploaded skin had the wrong checksum! Try uploading again.", 0, 1);
}
my $subst = {};
my $exist_flag = -e "$DCONF->{admin_dir}/skins/$FORMref->{skin}.tmpl";
$exist_flag = 0 if $FORMref->{overwrite} == 1;
if ($FORMref->{confirm} == 1 && ! $exist_flag) {
if (-e "$DCONF->{admin_dir}/skins/$FORMref->{skin}.tmpl") {
@out = sort { my $j = $a->{dir} cmp $b->{dir}; return $j if $j; return $a->{file} cmp $b->{file} } @out;
$subst->{templates} = \@out;
}
if ($FORMref->{menu} == 5) {
$subst->{topics} = board_topics();
}
screen_out("appr-mgr", $subst);
}
###
### get_template_info
###
### Gets information from 'Description' comment in template file
###
sub get_template_info {
my ($dir, $file) = @_;
return "" if ! open(FILE, "$DCONF->{admin_dir}/template/$dir/$file.tmpl");
while (<FILE>) {
if (m|^\s*#\s*DESCRIPTION:\s*(.*)|) {
close (FILE);
return $1;
}
}
close (FILE);
return "";
}
###
### appear_select_skin
###
### Confirms user's selection of a skin
###
sub appear_select_skin {
my ($FORMref) = @_;
my $skinname = $FORMref->{skname};
error_message("Skin Selection Error", "That skin name is invalid. Skin file names must contain only alphanumeric characters.", 0, 1) if $skinname !~ m|^[\w\-\.]+$|;
foreach my $k (keys %{ $subst->{skin}->{optf} }) {
push @k, { name => $k, value => $subst->{skin}->{optf}->{$k}->{value}, explanation => $subst->{skin}->{optf}->{$k}->{explanation} };
}
$subst->{forced} = \@k;
}
screen_out("appr-sel", $subst);
}
###
### appear_save_skin
###
### Saves the skin in the options file
###
sub appear_save_skin {
my ($FORMref) = @_;
my $skinname = $FORMref->{choice};
error_message("Skin Selection Error", "That skin name is invalid. Skin file names must contain only alphanumeric characters.", 0, 1) if $skinname !~ m|^[\w\-\.]+$|;
dreq("adm-opts");
my $new_opt = {};
$new_opt->{skinchoice} = $skinname;
my $o = get_skin_info($skinname);
if ($FORMref->{colors}) {
foreach my $t (keys(%{ $o->{opt} })) {
$new_opt->{$t} = $o->{opt}->{$t};
}
}
if ($FORMref->{fa} ne "") {
my %u = map { $_, 1 } split(/,/, $FORMref->{fa});
foreach my $key (keys %{ $o->{optf} }) {
$new_opt->{$key} = $o->{optf}->{$key}->{value} if $u{$key};
}
}
options_save($new_opt);
}
###
### appear_preview_skin
###
### Preview the appearance of a skin that is not as of yet applied