#!/usr/local/bin/perl unshift(@INC,"/usr/local/lib/perl5"); require "ctime.pl"; require Cookie; require CGI; package Plank; umask 0; sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless $self, $class; if (@_ > 0) { $self->initialize(@_); } return $self; } sub initialize { my $self = shift; my %params = @_; foreach (keys %params) { $self->{$_} = $params{$_}; } } sub id { my $self = shift; return $self->{id}; } sub brief { my $self = shift; return $self->{brief}; } sub long { my $self = shift; return $self->{long}; } sub author { my $self = shift; return $self->{author}; } sub comments { my $self = shift; return $self->{comments}; } sub print { my $self = shift; print "Content-type: text/plain\n\r\n\r"; foreach (keys %{$self}) { print "$_=".$self->{$_}."\n"; } } sub read { my $self = shift; $self->read_part("brief"); $self->read_part("long"); $self->read_part("author"); $self->{author} =~ s/[\s]*$//; } sub write { my $self = shift; if ($self->{id} == 0) { $self->{id} = time; mkdir("plankdirs/".$self->{id},0777) || printf("mkdir plankdirs/".$self->{id}." failed!!"); chmod 0777, "plankdirs/".$self->{id}; } $self->write_part("brief"); $self->write_part("long"); $self->write_part("author"); } sub read_part { my $self = shift; my $part = shift; open(DATA,"plankdirs/".$self->{id}."/$part") ; $self->{$part} = ""; while () { $self->{$part} .= $_; } close(DATA); } sub write_part { my $self = shift; my $part = shift; open(DATA,">plankdirs/".$self->{id}."/$part") || printf(">plankdirs/".$self->{id}."/$part failed!!!") ; print DATA $self->{$part}; close(DATA); } sub add_comment { my $self = shift; my $comment = shift; open(DATA,">>plankdirs/".$self->{id}."/comments") || print "couldnt open >>plankdirs/".$self->{id}."/comments"; print DATA $comment."\n


\n"; close(DATA); } sub write_votes { open(OUT,">votes.html") || printf("couldnt open votes.html!"); my $cookies = new Cookie; my $who = $cookies->get(who); my $ewho = CGI::escape($who); print OUT < It's Your Party wanna go HOME now...

What is this?

It's Your Party
Create a new plank of your own.

Click on a plank to see a longer description and to make comments. EOQ my %votes = (); open(IN,"ls -1 plankdirs | sort -rn |") || die("cant open planks"); while () { chop($_); for $vote (1 .. 7) { $votes{$_}{vote}{$vote} = 0; } $votes{$_}{total_vote} = 0; } my $plank = new Plank; open(VOTES,"sort -u votes |"); while () { chop($_); ($voter,$id,$vote) = split(/\|/,$_); $votes{$id}{vote}{$vote} += 1; $votes{$id}{total_vote} += 1; } foreach $id (sort {$a <=> $b} keys %votes) { $plank->initialize( id => $id ); $plank->read; print OUT "\n"; if ($votes{$id}{total_vote} <= 0) { print OUT "\n"; next; } for $vote (1 .. 7) { $color = sprintf "#FFFF%2.2x", 0xFF - (0xFF * ($votes{$id}{vote}{$vote}/$votes{$id}{total_vote})); print OUT "\n"; } print OUT "\n"; } print OUT <
Please spread the word - tell your friends that it's Their Party too. All ideas, comments, suggestions are more than welcome - The Mgmt. EOQ close(OUT); } 1;
Plank Strongly Disagree Disagree Mixed Feelings Agree Strongly Agree Don't Know Don't Care
" .$plank->brief."total_vote = [".$votes{$id}{total_vote}."]\n"; if ($votes{$id}{vote}{$vote} > 0) { printf OUT "%0.2f", (100.0 * ($votes{$id}{vote}{$vote}/$votes{$id}{total_vote})); print OUT "
".$votes{$id}{vote}{$vote}; } print OUT "