){
chop;
push(@ONGraw, $_)
}
flock(DATEI,8);
close(DATEI);
}
# Now split data
$i = 0;
@tempong = ("");
@tempdata = ("");
@tempong = sort(@ONGraw);
foreach(@tempong){
if($_ ne ""){
@tempdata = split(/\t/, $_);
$ONGname[$i] = $tempdata[0];
$ONGurl[$i] = $tempdata[1];
$ONGdesc[$i] = $tempdata[2];
$ONGmail[$i] = $tempdata[3];
$ONGtel[$i] = $tempdata[4];
$i++;
}
}
}
# --------- Writes new dataset to file ---
sub WriteData {
undef $DataError;
if($in{'go'} eq "rec"){
# Security check for SSI
if($in{'ngoname'}=~//i){$DataError=1}
if($in{'ngourl'} =~//i){$DataError=1}
if($in{'ngodesc'}=~//i){$DataError=1}
if($in{'ngomail'}=~//i){$DataError=1}
if($in{'ngotel'} =~//i){$DataError=1}
# Everything's fine? Then write it to disk:
if(defined($DataError)){
print"content-type: text/html\n\nError!";
die;
} else {
$tempong = "";
$tempong = $in{'ngoname'}."\t".$in{'ngourl'}."\t".$in{'ngodesc'}."\t".$in{'ngomail'}."\t".$in{'ngotel'}."\n";
push(@ONGraw, $tempong);
if(open(DATEI, ">>gifs/ongs.dat")){
flock(DATEI,2);
print DATEI $tempong;
flock(DATEI,8);
close(DATEI);
} else {
print"content-type: text/html\n\nError while writing to NGO datafile! Please report this error to Christian Steimel. Thank you!";
}
}
}
}
# --------- Make letters HTML readable, i.e. á = á etc. ---
sub CleanData{
$i = 0;
foreach $i (0 .. $#ONGname){
$ONGname[$i] =~ s/á/á/g;
$ONGname[$i] =~ s/Á/Á/g;
$ONGname[$i] =~ s/é/é/g;
$ONGname[$i] =~ s/É/É/g;
$ONGname[$i] =~ s/í/í/g;
$ONGname[$i] =~ s/Í/Í/g;
$ONGname[$i] =~ s/ó/ó/g;
$ONGname[$i] =~ s/Ó/Ó/g;
$ONGname[$i] =~ s/ú/ú/g;
$ONGname[$i] =~ s/Ú/Ú/g;
$ONGname[$i] =~ s/ñ/ñ/g;
$ONGname[$i] =~ s/Ñ/Ñ/g;
$ONGdesc[$i] =~ s/á/á/g;
$ONGdesc[$i] =~ s/Á/Á/g;
$ONGdesc[$i] =~ s/é/é/g;
$ONGdesc[$i] =~ s/É/É/g;
$ONGdesc[$i] =~ s/í/í/g;
$ONGdesc[$i] =~ s/Í/Í/g;
$ONGdesc[$i] =~ s/ó/ó/g;
$ONGdesc[$i] =~ s/Ó/Ó/g;
$ONGdesc[$i] =~ s/ú/ú/g;
$ONGdesc[$i] =~ s/Ú/Ú/g;
$ONGdesc[$i] =~ s/ñ/ñ/g;
$ONGdesc[$i] =~ s/Ñ/Ñ/g;
}
}
# --------- Return part of NGO list ---
sub DisplayList{
# How many displays per page:
$displays=30;
$total=$#ONGraw-1;
# If no pagenumber was submited, display the first page.
if(!$in{'p'}){$in{'p'}=1}
# Calculate Start and End number
$displayStart = (($in{'p'}-1) * $displays) + 1;
$displayEnd = ($in{'p'} * $displays);
# Avoid possible (and impossible) errors
if($displayEnd > $total) { $displayEnd=$total; }
if($displayStart > $total) { $displayStart=($total-$displays); }
if($displayStart < 1) { $displayStart=1; }
if($displayEnd < 1) { $displayEnd=$displays; }
if($displayEnd < $displayStart) { $displayStart=1; $displayEnd=$displays; }
# Now print BACK, NEXT and which items listed:
print"";
print"| Items $displayStart to $displayEnd | ";
if($in{'p'} > 1){print"PREVIOUS | "}
if($total>$displayEnd){print"NEXT | "}
print"
";
# Display the list now
for($i=$displayStart; $i<=$displayEnd; $i++) {
print"
";
}
# Now print BACK, NEXT and which items listed:
print"";
print"| Items $displayStart to $displayEnd | ";
if($in{'p'} > 1){print"PREVIOUS | "}
if($total>$displayEnd){print"NEXT | "}
print"
";
}
# --------- Return HTML page to client ---
ReadParse;
print "content-type: text/html\n\n";
print $tp1;
# .ngo { font-family: arial, helvetica, sans-serif; font-size: 9pt; font-style: none; font-weight: normal; text-decoration: none; color: #20266f }
# .ngot { font-family: arial, helvetica, sans-serif; font-size: 9pt; font-style: none; font-weight: bold; text-decoration: none; color: #c7cbff }
# a.ngo { font-weight: bold; }
# Step to main part of table and print intro text:
print"This list of mexican non governmental organizations is hosted by Universidad de las Americas - Puebla (UDLA) in Mexico, and maintained by the office of Dr. Paul Rich from UDLA and Stanford University.
";
# Now check what page to display:
if($in{'go'} eq "new"){
exit 0;
# Form to register new NGO:
print"To register a new organization, please fill in this form. Please write the name, a short description, the address of their webpage, email and telephone number.
";
print"Thank you for sharing the infornmation with other researchers in Mexico and worldwide!
";
print"