File: webAdd.cgi

package info (click to toggle)
plan 1.8.4-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,964 kB
  • ctags: 1,986
  • sloc: ansic: 24,493; perl: 1,361; makefile: 531; sh: 516; yacc: 119; sed: 17
file content (160 lines) | stat: -rwxr-xr-x 3,910 bytes parent folder | download | duplicates (7)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/perl
# author: Michel Bourget, hacked for plan 1.8 by thomas@bitrot.de
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
require ("./cgi-lib.pl") || die "can\'t require cgi-lib.pl: $!";;
require ("./common.pl") || die "can\'t require common.pl: $!";;

#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
sub header {
   local($mo,$yr)=@_;

   print "Content-type: text/html


<HTML>
<HEAD>
<TITLE>January 1999</TITLE>
</HEAD>
<BODY>
";
} # header

#--------------------------------------------------------------------------
# Print the content of the FORM
#--------------------------------------------------------------------------
sub add {
   local($dorep);

   $start="00000000"; 
	if ( $in{mo_start} <=9 ) {
   		substr($start,1,1)=$in{mo_start};
	} else {
		substr($start,0,2)=$in{mo_start};
	}
	if ( $in{jr_start} <=9 ) {
		substr($start,3,1)=$in{jr_start};
	} else {
		substr($start,2,2)=$in{jr_start};
	}
	if ( $in{type} eq "Appointment" ) { 
		if ( $in{hr_start} < 1000 ) {
			substr($start,5,3)=$in{hr_start};
		} else {
			substr($start,4,4)=$in{hr_start};
		}
	}
#  -l option
   $len="0000";
	if ( $in{type} eq "Appointment" ) {
		if ( $in{hr_end} < 10  ) {
			substr($len,3,1)=$in{hr_end};
		} 
		else {
			if ( $in{hr_end} < 100  ) {
				substr($len,2,2)=$in{hr_end};
			} 
			else {
				if ( $in{hr_end} < 1000 ) {
					substr($len,1,3)=$in{hr_end};
				} 
				else {
					substr($len,0,4)=$in{hr_end};
				}
			}
		}
	}
#  -u option
$user=$in{group};
#  Don't ask why ... user contains a \0 at the end ...
#  Must be a bug in cgi-lib in readparse
   chop $user;

# Testing if user=none is entered 
   if ( $in{group} eq "none" ) {
 	print "User None specified: nothing added \!<br>\n";
 	return;
   }

#  -l or -L
   if ( $in{type} eq "Appointment" ) {
	$long="-l $len";
   } else {
	$long="-L";
   }

# -r, -d, -D repeat options (hacked 21.12.98 thomas@bitrot.de)

   $dorep=0;
   $rep=" ";
   if ( $in{mday} ne "No" ) {			# on a day of the month
	$dorep=1;
	$rep=$rep."-d $in{mday} ";
   }
   if ( $in{wday} ne "No" ) {			# on a weekday
	$dorep=1;
	$rep=$rep."-D $in{wday} ";
   }
   if ( $in{ndays} ne "No" ) {			# every n days
	$dorep=1;
	$rep=$rep."-r $in{ndays} ";
   }
   if ( $dorep == 1 ) {				# end date
   	$till="00000000"; 
	if ( $in{mo_end} <=9 ) {
   		substr($till,1,1)=$in{mo_end};
	} else {
		substr($till,0,2)=$in{mo_end};
	}
	if ( $in{jr_end} <=9 ) {
		substr($till,3,1)=$in{jr_end};
	} else {
		substr($till,2,2)=$in{jr_end};
	}
	$rep=$rep."-e $till";
#	Testing if till > start 
	$nstart = substr($start,0,4);
	$ntill  = substr($till,0,4);
	if ( $ntill <= $nstart ) {
		print "Error: Stop Date MUST be at least one day after Start Date \!<br>\n";
		return;
	}
   }

   $data="$in{descr}";

#  print "Not ready yet : below are debug messages<br>";
#  user add a \0 appended to it ... that's why data was not passed
#  to the dam script with system or open() statement

   $cmd="/usr/local/bin/plan $start -W $long $rep -u $user \"$data\"";
#  system("$cmd");
        open ( IN , "$cmd |");
        @error=<IN>;
        close(IN);
        foreach $line ( @error ) {
                print "$line\n";
        }
   print "Done\! ... Please <U>\"Get Calendar\"</U> to update your Scheduler View.";
} # form

#--------------------------------------------------------------------------
# Print the Footer
#--------------------------------------------------------------------------
sub footer {
   print <<"END";
END
   print "</HTML>";
} # footer

#--------------------------------------------------------------------------
# Main Function 
#--------------------------------------------------------------------------
   &ReadParse;

   &header;
   &add;
   &footer;