#!/usr/bin/perl
use CGI qw(:standard);

print "Content-type: text/html\n\n" unless $ARGV[0] eq "bh";

chdir("/home12c/sub007/sc13648-GPVH/") || print "Couldn't change directory $!<BR>\n";

$cookie = $ENV{"HTTP_COOKIE"};
$id = $1 if $cookie =~ m/cpid\=([^;,]+)/;
$subfolder = substr($id,0,1);

$time = time;

open(DATA,"CPs/$subfolder/$id/girl.txt") || open(DATA,"CPs/$subfolder/$id/girl.txt");
while ($_ = <DATA>) {
	$info{$1} = $2 if m/^([^=]+)\=(.*)/;
}
close(DATA);

$event = param("event");

if ($event eq "makechanges") {
	@targets = param();
	MCLOOP: foreach $target (@targets) {
		next MCLOOP if $target eq "event";
		$value = param($target);
		$value =~ s/\{//gm;
		$feminfo{$target} = $value if $value || $value eq "0";
	}
	open(DATA,">CPs/$subfolder/$id/femchoices.txt");
	foreach $key (keys(%feminfo)) {
		$value = $feminfo{$key};
		print DATA "$key=$value\n";
	}
	close(DATA);
	exec "cp/cgi-bin/main.pl","bh";
}

$name = $info{"name"};
$gender = $info{"gender"};
$age = $info{"age"};

push @togo, qq~These are the general trainings available to females. If you select the General Training option, you get phrases from these categories.\n~;

if (open(DATA,"CPs/$subfolder/$id/femchoices.txt") || open(DATA,"CPs/$subfolder/$id/femchoices.txt") ) {
	while ($_ = <DATA>) {
		$feminfo{$1} = $2 if m/^([^=]+)\=(.*)/;
	}
	close(DATA);
}
else {
	%feminfo = ("guy1","on","guy2","on","needself","on","female","on","patriarch","on","getbf","on","sharefeelings","on","affirmation","on","affirmationmale","on","ofwomen","on","feelings","on","noconflict","on");
}

push @togo, qq~<form method=post action="/cgi-bin/rare/aboutyou3b.pl">\n~;


@ic = ("guy1","guy2","needself","female","patriarch","getbf","sharefeelings","affirmation","affirmationmale","ofwomen","feelings","noconflict");
$explanation{"guy1"} = "Training to like being around a male";
$explanation{"guy2"} = "Training for light physical contact with a male, usually him touching you";
$explanation{"needself"} = "Training for light physical contact with a male, usually him touching you";
$explanation{"female"} = "Training for light physical contact with a male, usually him touching you";
$explanation{"patriarch"} = "Training for light physical contact with a male, usually him touching you";
$explanation{"getbf"} = "Training for light physical contact with a male, usually him touching you";
$explanation{"sharefeelings"} = "Training for sharing your feelings";
$explanation{"affirmation"} = "Training to feel attractive";
$explanation{"affirmationmale"} = "Training to want a male to think you are attractive";
$explanation{"ofwomen"} = "Training to let a man lead";
$explanation{"feelings"} = "Training for having feelings";
$explanation{"noconflict"} = "Training to want to avoid conflict";

foreach $topic (@ic) {
	$checked = "";
	$checked = "checked" if $feminfo{$topic} eq "on";
	$explanation{$topic} = $topic unless $explanation{$topic};
	push @togo, qq~<div style=left-margin:7><input type=checkbox name=$topic $checked> $explanation{$topic}</div>\n~;
}

push @togo, qq~<input type=hidden name=event value=makechanges><BR><br><INPUT TYPE=SUBMIT VALUE="Enter"></div></form>\n~;


printonblankerpage(@togo);

sub printonblankerpage {
	@toprint = @_;
	chdir("/home12c/sub007/sc13648-GPVH/cp");
	open(DATA,"cgi-bin/shells/startshell.htm") || open(DATA,"cgi-bin/shells/startshell.htm")  || print "There was a problem reading shellpage: $!";
	@lines = <DATA>;
	close(DATA);
	$contentmarker = "<!--content-->";

	foreach (@lines) {
		if (m/$contentmarker/o) {
			print @toprint;
		}
		else {
			print;
		}
	}
	exit;
}

