#!/usr/local/bin/perl -w # # xhibition admin.cgi (c) Marc Majcher 2002 # # Administrative interface for editing XML gallery configuration # files. Probably not the prettiest way to do it, but hey. # # Warning: Ass-ugliness ahead. # # I know, there's a ton of HTML in here, and that's # just plain wrong, but it's just an admin script, # so deal with it. use strict; use CGI qw(:standard); use XML::Twig; my $password = "ph0t0s"; my $cookie_name = "xhibition-admin"; my $cookie = cookie($cookie_name); my $crypted = crypt($password,"xh"); my $action = param('action'); my $conf_dir = "config"; my $image_dir = "images"; my $template_dir = "$conf_dir/admin"; my $xhconf_file = "$conf_dir/xhconf.xml"; my $table_width = 4; my %actions = ( index => \&index, show_gallery => \&show_gallery, edit_gallery => \&edit_gallery, show_image => \&show_image, edit_image => \&edit_image, render_all => \&render_all, render_gallery => \&render_gallery, import_directory => \&import_directory, generate_thumbs => \&generate_thumbs, ); $action = 'index' unless ((defined $action) && (defined $actions{$action})); # read gallery list from XML file my %config = read_config($xhconf_file); my $xhibition_url = $config{'base_url'}; my @gallery_files = @{$config{'galleries'}}; if ($crypted eq $cookie) { # Main section - process arguments blah blah blah my ($bodytext, $location) = &{$actions{$action}}; if (defined $location) { print <
Enter Password:
HTML if (@new_dirs) { $content .= <Select a new directory to import:
HTML } else { $content .= "
(Put new image directories in \$XHROOT/$image_dir to add galleries.)" } $content .= <
HTML return $content; } sub show_gallery { my $gallery = param('gallery'); my $t = parse_gallery($gallery); my $r = $t->root; my $gallery_name = $r->att('name'); $gallery_name =~ s/\s/_/g; my $gallery_title = $r->first_child('gallery_title')->text; my $gallery_text = $r->first_child('gallery_text')->text; my $gallery_teaser = $r->first_child('gallery_teaser')->text; my $gallery_date = $r->first_child('gallery_date')->text; my $display_gallery = $r->att('display'); my $display = "checked" unless (lc($display_gallery) eq "false"); my $html = <