1#!/usr/local/bin/perl
2
3#
4# Authentic Theme (https://github.com/authentic-theme/authentic-theme)
5# Copyright Ilia Rostovtsev <programming@rostovtsev.io>
6# Licensed under MIT (https://github.com/authentic-theme/authentic-theme/blob/master/LICENSE)
7#
8use strict;
9
10our (%in, $current_theme, $config_directory, $get_user_level, %theme_text, $has_usermin, $has_usermin_conf_dir);
11
12do("$ENV{'THEME_ROOT'}/authentic-lib.pl");
13
14$get_user_level ne '0' && error($theme_text{'theme_error_access_not_root_user'});
15
16theme_make_config_dir();
17
18my $lsw = "background_content.png";
19my $lw  = "/$current_theme/$lsw";
20
21if ($in{'unauthenticated_bg'} eq "1" &&
22    length $in{'unauthenticated_bg_file'})
23{
24    unlink_file($config_directory . $lw);
25    write_file_contents($config_directory . $lw, $in{'unauthenticated_bg_file'});
26    if ($has_usermin) {
27        unlink_file($has_usermin_conf_dir . $lw);
28        write_file_contents($has_usermin_conf_dir . $lw, $in{'unauthenticated_bg_file'});
29    }
30} elsif ($in{'unauthenticated_bg'} ne "1") {
31    unlink_file($config_directory . $lw);
32    if ($has_usermin) {
33        unlink_file($has_usermin_conf_dir . $lw);
34    }
35}
36
37redirect("settings-backgrounds.cgi?saved=1");
38