#!/usr/bin/perl # *** Version 2.1 -- changed 22.09.2000 $starttime = time; ################### # THIS HERE WAS ADDED 2002-09-05 ################### my $tpcont=""; unless(open(DB,"../Templates/template01.dwt")) { print"content-type: text/html\n\nCould not find file ../Templates/template01.dwt
$!"; exit; } flock(DB,2); my ($tp1,$tp2)=split(/$tpcont/,join("",,2)); close(DB); # ---------- Global VARs --- @ONGraw = (""); @ONGname = (""); @ONGurl = (""); @ONGdesc = (""); @ONGmail = (""); @ONGtel = (""); # ---------- Read POST data --- sub ReadParse{ local (*in) = @_ if @_; local ($i, $loc, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET"){ $in = $ENV{'QUERY_STRING'} } elsif ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN,$in,$ENV{'CONTENT_LENGTH'}) } @in = split(/&/,$in); foreach $i (0 .. $#in){ # Convert pluses to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $thekey[$i] = $key; $val =~ s/%0D%0A/
/g; # Wenn das Feld article Absaetze enthaelt, diese in
umwandeln. $val =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s///g; # Filter out SSI $theval[$i] = $val; # Associate key and value $in{$key} .= " " if (defined($in{$key})); # is the multiple separator $in{$key} .= $val; } } # --------- Read in ONG data --- sub ReadData { # Read in complete list: if(open(DATEI, "){ 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""; if($in{'p'} > 1){print""} if($total>$displayEnd){print""} print"
Items $displayStart to $displayEndPREVIOUSNEXT

"; # Display the list now for($i=$displayStart; $i<=$displayEnd; $i++) { print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print"
".$ONGname[$i]."

".$ONGdesc[$i]."

Tel. » ".$ONGtel[$i]."

"; } # Now print BACK, NEXT and which items listed: print""; print""; if($in{'p'} > 1){print""} if($total>$displayEnd){print""} print"
Items $displayStart to $displayEndPREVIOUSNEXT

"; } # --------- 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"
"; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print"
Please fill in all fields:

Name:

Description:

WWW address:

Email address:

Telephone:

If anything is correct:


"; } elsif($in{'go'} eq "rec"){ exit 0; # Save a new entry: &ReadData; # Read in all NGO. &WriteData; # Ad new NGO, check for SSI and write back to file. print"

Thank you for sharing the infornmation with other researchers in Mexico and worldwide!

"; print"

The following information was registered in our database of mexican non governmental organizations:

"; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print""; print"
".$in{'ngoname'}."

".$in{'ngodesc'}."

".$in{'ngotel'}."

Go back to NGO list ...

"; } else { # Display List: &ReadData; # Read in all NGO. &CleanData; # Translate data for HTML. # print"

If you do know of, or are member in a mexican NGO (civil movement, not companies, etc.), Dr. Rich would like to invite you to share this information by filling in a very short form online. The NGO will be registered immedeately and included into this list.

"; print"

Dr. Rich and his team hopes that this list will be usefull for your investigations on mexican civil society. Any suggestions or comments are extreamly welcomed and may be send by email to Dr. Paul Rich.

"; print"

Currently, the database has $#ONGname mexican Non Governmental Organizations (NGOs) registered.

"; &DisplayList; } print $tp2;