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, $remote_user, %theme_text); 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 16my @files = ($config_directory . "/$current_theme/styles.css", 17 $config_directory . "/$current_theme/scripts.js", 18 $config_directory . "/$current_theme/scripts.pl", 19 $config_directory . "/$current_theme/favorites-$remote_user.json", 20 $config_directory . "/$current_theme/custom-lang"); 21my $file = html_escape($in{'file'}); 22$file = $files[0] if (!$file); 23&ui_print_header(undef, $theme_text{'settings_right_theme_extensions_title'}, undef, undef, undef, 1); 24print '' . &theme_text('settings_right_extensions_title') . ' 25 <p></p>'; 26print "<form action=\"settings-editor_read.cgi\" method=\"get\" class=\"margined-bottom-3\">\n"; 27print '<div class="pull-right" style="margin-top: 15px; margin-right: 24px;"><span class="badge label-default">' 28 . 29 ( $file =~ /.css/ ? $theme_text{'theme_fileformat_css'} : 30 $file =~ /.json/ ? $theme_text{'theme_fileformat_json'} : 31 $file =~ /.js/ ? $theme_text{'theme_fileformat_js'} : 32 $file =~ /.pl/ ? $theme_text{'theme_fileformat_perl'} : 33 $theme_text{'theme_fileformat_plain_text'} 34 ) . 35 '</span></div>'; 36print "<input type=submit value='$theme_text{'settings_right_file_edit'}'>\n"; 37print "<select name=\"file\">\n"; 38 39foreach my $f (@files) { 40 printf "<option %s>%s</option>\n", $f eq $file ? 'selected' : '', $f; 41} 42print "</select></form>\n"; 43 44my $data = &read_file_contents($file); 45 46print &ui_form_start("settings-editor_write.cgi", "form-data"); 47print &ui_hidden("file", $file), "\n"; 48print &ui_textarea("data", 49 ($file =~ '.json' ? ($data =~ /\{(?:\{.*\}|[^{])*\}/sg) : 50 $data 51 ), 52 20, 80, undef, undef, 53 "style='width: 100%' " 54 . 55 ( $file =~ '.pl' ? 'placeholder="' . $theme_text{'theme_fileformat_perl_placeholder'} . '"' : 56 '' 57 ) . 58 ""); 59print &ui_form_end([["save", $theme_text{'theme_xhred_global_save'}]]); 60&ui_print_footer("tconfig.cgi", $theme_text{'right_return_theme_options'}); 61