/[synchroedit]/espi.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /espi.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Sun Apr 15 23:39:32 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 991 byte(s)
split configuration into YAML file
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use CGI;
6 use CGI::Carp 'fatalsToBrowser';
7
8 use Data::Dump qw/dump/;
9 use YAML::Syck;
10
11 $| = 1;
12
13 my $config_file = $0;
14 $config_file =~ s/\.cgi$/.yaml/;
15 my $config = LoadFile( $config_file ) or die "can't open $config_file: $!";
16
17 my $espi_hook = {
18 # 'authenticate-user' => 'ACCESS GRANTED ADMIN',
19 # 'authenticate-user' => 'ACCESS GRANTED',
20 'authenticate-user' => sub {
21 my $param = shift;
22 warn "param = ",dump( $param );
23 my $ret = 'ACCESS GRANTED';
24 $ret .= ' ADMIN' if defined( $config->{admins}->{ $param->{uid} } ) && $config->{admins}->{ $param->{uid} } eq $param->{pwd};
25 return $ret;
26 }
27 };
28
29 my $cgi = new CGI;
30
31 print $cgi->header();
32
33 my $v = $cgi->Vars;
34
35 warn dump( $v );
36
37 my $hook = $v->{espi_hook} || die "no espi_hook?";
38
39 die "can't find hook for $hook" unless defined( $espi_hook->{ $hook } );
40
41 if ( ref( $espi_hook->{ $hook } ) eq 'CODE' ) {
42 print $espi_hook->{ $hook }->( $v );
43 } else {
44 print $espi_hook->{ $hook }
45 };
46 print "\n";

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26