File: web

package info (click to toggle)
slash 2.2.6-8etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,672 kB
  • ctags: 1,915
  • sloc: perl: 23,113; sql: 1,878; sh: 433; makefile: 233
file content (66 lines) | stat: -rwxr-xr-x 1,585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2001 by Open Source Development Network. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id: web,v 1.1.2.1 2001/03/29 17:28:49 pudge Exp $

# this program does some really cool stuff.
# so i document it here.  yay for me!

use strict;
use Slash;
use Slash::Display;
use Slash::Utility;
use vars qw($VERSION);

($VERSION) = ' $Revision: 1.1.2.1 $ ' =~ /\$Revision:\s+([^\s]+)/;


# this is an example main().  feel free to use what you think
# works best for your program, just make it readable and clean.

use constant ALLOWED	=> 0;
use constant FUNCTION	=> 1;

sub main {
	my $slashdb   = getCurrentDB();
	my $constants = getCurrentStatic();
	my $user      = getCurrentUser();
	my $form      = getCurrentForm();

	# possible value of "op" parameter in form
	my %ops = (
	# Ex:	op	=> [is_allowed,		\&function	],
		foo	=> [ 1,			\&showFoo	],
		bar	=> [ 1,			\&saveBar	],
		baz	=> [ !$user->{is_anon},	\&editBaz	],
		buz	=> [ $user->{is_admin},	\&createBuz	],
		default	=> [ 1,			\&showFoo	]
	);

	# prepare op to proper value if bad value given
	my $op = $form->{op};
	if (!$op || !exists $ops{$op} || !$ops{$op}[ALLOWED]) {
		$op = 'default';
	}

	header(getData('header'));	# from data;SCRIPTNAME;default

	# dispatch of op
	$ops{$op}[FUNCTION]->($slashdb, $constants, $user, $form);

	# writeLog('SOME DATA');	# if appropriate
	footer();
}

sub showFoo {
	my($slashdb, $constants, $user, $form) = @_;
	# ...
}

# etc.

createEnvironment();
main();

1;