/[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

Annotation of /espi.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Sun Apr 15 23:39:32 2007 UTC (14 years, 7 months ago) by dpavlin
File size: 991 byte(s)
split configuration into YAML file
1 dpavlin 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 dpavlin 3 use YAML::Syck;
10 dpavlin 1
11     $| = 1;
12    
13 dpavlin 3 my $config_file = $0;
14     $config_file =~ s/\.cgi$/.yaml/;
15     my $config = LoadFile( $config_file ) or die "can't open $config_file: $!";
16 dpavlin 2
17 dpavlin 1 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 dpavlin 3 $ret .= ' ADMIN' if defined( $config->{admins}->{ $param->{uid} } ) && $config->{admins}->{ $param->{uid} } eq $param->{pwd};
25 dpavlin 1 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