#!/usr/bin/perl
use CGI qw(:standard);
print "Content-type: text/html\n\n" unless $ARGV[0] eq "bh";

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

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

#system "/home12c/sub007/sc13648-GPVH/cp/cgi-bin/rare/recordactivity.pl", $id, "Visiting Christina";

($event = $ARGV[0]) || ($event = param("event"));

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

$hl = $info{"hl"};

open(DATA,"CPs/$subfolder/$id/girl.txt") || open(DATA,"CPs/$subfolder/$id/girl.txt");
while ($_ = <DATA>) {
	$girlinfo{$1} = $2 if m/^([^=]+)\=(.*)/;
}
close(DATA);
$name = $girlinfo{"name"};
push @togo, qq~Welcome, $name<BR>\n~;

$hyppic = $girlinfo{"hyppic"};

if ($hyppic=$girlinfo{"hyppic"}) {
	opendir(DATA,"/home12c/sub007/sc13648-GPVH/cp/images/images/$hyppic");
	@filenms = readdir(DATA);
	closedir(DATA);
	@filenms = grep m/\w\./, @filenms;
	$r = int(rand(@filenms));
	push @togo, qq~<img src=/images/images/$hyppic/$filenms[$r] align=right class=picture title="Welcome">~;
}


push @togo, qq~<a href=/t/start/hyppics.htm>Decide on pictures for the hypnotist</a>. Do this first~ unless $hyppic;
push @togo, qq~<p><a href=/cgi-bin/creatorh.pl?fl=chrv.txt;start=z1>Explanation</a>. Read this next.~;
push @togo, qq~<p><a href=/cgi-bin/creatorh.pl?fl=chrv.txt;start=a1>First Induction</a>. Includes safety cop.~;

push @togo, qq~<p>General Inductions<ul>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=g1>Intro</a> Gives a meaning to counting from 10 to 1.</li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp7v.txt;start=g1>General Relaxation</a></li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp10v.txt;start=h1>Being accepting during training</a></li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp7v.txt;start=a1>Improving Induction.</a> This is good for starting.</li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp7v.txt;start=d1>Enjoy training</a> Another good starter.</li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhyp2.txt;start=z1>Body Image (basic)</a></li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhyp2.txt;start=a1>Dissociations</a> Seperating memories and concerns</li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhyp2.txt;start=b1>Sleep Hypnosis</a> Having these hypnoses while you sleep</li>~;
push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhyp2.txt;start=d1>Triggers</a> Enforcing your triggers</li>~;

push @togo, qq~</ul>~;

if ($girlinfo{"doll"} eq "yes" || $name =~ m/doll/i) {
	push @togo, qq~<h3>Being a Doll</h3><ul>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhypdoll.txt;start=z1>mental/key</a>Being hypnotized like a doll and having a key.</li>~;
	push @togo, qq~</ul>~;
}

if ($girlinfo{"gender"} eq "female") {
	push @togo, qq~<h3>Being Female</h3><ul><li><a href=/cgi-bin/creatorh.pl?fl=hyp1v.txt;start=a1>An induction for females</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=i1>Showing Emotions</a>Tolerance and understand of men who are not allowed to freely show their emotions.</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhypf.txt;start=c1>Not Being Logical</a> Relying on emotions instead of logic.</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=a1>Not being critical</a> Longish. Some negative imagery</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=j1>Making things right</a> Finding happiness. Includes following rules and accepting punishments.</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp5v.txt;start=a1>Entry</a> Simple Body Image</li>~;

	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp1v.txt;start=g1>Body Image I</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp1v.txt;start=j1>Body Image III</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp1v.txt;start=jj1>Body Image IV</a></li>~;

	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp13.txt;start=d1 target=_top>Body Image V (hypnoimagery)</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhypf.txt;start=a1>Needing Men</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=newhypf.txt;start=b1>Needing Men II</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp9v.txt;start=d1>Mother-daughter advice</a> .</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp6v.txt;start=h1>Crying I</a> Long story in which you cry. Short-phrase style. Long.</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=c1>Babies are cute</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=e1>Babies II</a> Training to be caring.</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp8v.txt;start=f1>Babies III</a> Training to be caring, without the explanation of Babies II</li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp5v.txt;start=e1>breastfeeding</a></li>~;
	push @togo, qq~<li><a href=/cgi-bin/creatorh.pl?fl=hyp7v.txt;start=f1>Tolerating Pain and Suffering</a></li>~;
	push @togo, qq~</ul>~;
}

if ($girlinfo{"age"} < 5) {
	push @togo, qq~<h3>Age Play</h3><BR><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=a1>Lose your ability to use long words.</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=b1>Losing years and experience.</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=d1>Clean and dry</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=e1>relaxing (diaper)</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=f1>eating safe foods</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=g1>thumb sucking</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=h1>being good</a>~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hypbabv.txt;start=c1>Learning</a>. Transferring Youth Skills to other realities.~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hyp10v.txt;start=k1>wearing a diaper when you are here</a>.~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hyp10v.txt;start=m1>trust</a>. Being more trusting when you wear a diaper~;
}

if ($name eq "mai") {
	push @togo, qq~<h3>Just mai</h3>\n~;
	push @togo, qq~<br><a href=/t/hyppun/y1.htm>Memory</a>. Two stories for you to experience.~;
	push @togo, qq~<br><a href=/t/hyppun/z1.htm>Memory</a>. Story for you to experience.~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=newhyp2.txt;start=c1>English</a> English as a second language.~;
	push @togo, qq~<br><a href=/t/hyp6v/n1.htm>Identity</a> Pretty heavy suggestion about losing your old identity.~;
	push @togo, qq~<br><a href=/t/hyp6v/p1.htm>Identity</a> Even heavier. Allows some "negotiation".~;
	push @togo, qq~<br><a href=/t/hyp7v/e1.htm>Body Image</a> Discusses the male disguise you might have to wear sometimes.~;
	push @togo, qq~<br><a href=/cgi-bin/creatorh.pl?fl=hyp4.txt;start=a1> Trigger</a> See <a href=/t/chr/trigger.htm>trigger</a>~;
	push @togo, qq~<br><a href=/t/hyp10v/j1.htm>Pleasure</a>Connects your sexual pleasure to the harem girls~;
	push @togo, qq~<br><a href=/t/hyp6v/d1.htm>Write</a> Write a hypnosis.~;
	push @togo, qq~<br><a href=/t/hyp8v/j1.htm>Making things right</a> Finding happiness. Includes following rules and accepting punishments.~;
	push @togo, qq~<br><a href=/t/hyp8v/h1.htm>Night Visit</a> Suggests I might give you a hypnoimagery while you are about to sleep or sleeping. Probably you should be experienced with my hypnoimageries before doing this one.~;
	push @togo, qq~<br><a href=/t/hyp6v/f1.htm>Imagine Jack in you</a>~;

	push @togo, qq~<br><a href=/t/hyp2v/a1.htm>Harmony</a>~;
	push @togo, qq~<br><a href=/t/hyp2v/b1.htm>Harmony & improving induction</a>~;
	push @togo, qq~<br><a href=/t/hyp2v/c1.htm>Memory and body image</a> (requires Harmony & improving induction)~;
	push @togo, qq~<br><a href=/t/hyp2v/sgd1.htm>An example of effects without hypnosis</a> (but vicious)~;

	push @togo, qq~<br><a href=/t/hyp6v/sgc1.htm>Energy/Willpower</a> Better energy, willpower, and happiness when you are an obedient harem girl.~;
	push @togo, qq~<br><a href=/t/hyp2v/sge1.htm>Memories of outside the Harem</a> If memories outside the harem are causing you pain, this helps you not have those memories only when you are in the harem.~;
	push @togo, qq~<br><a href=/t/hyp2v/sgg1.htm>Concentration</a> Same as above -- good concentration if you have been obedient.~;
	push @togo, qq~<br><a href=/t/hyp2v/sgh1.htm>Happiness</a> Same as the two above.~;
	push @togo, qq~<br><a href=/t/hyp2v/j1.htm>Sleep</a> Practice your body awareness as you fall asleep in bed.~;
		push @togo, qq~<br><a href=/t/hyp6v/c1.htm>Energy/Willpower</a> Better energy, willpower, and happiness when you are an obedient harem girl.~;

	push @togo, qq~<br><a href=/t/hyp6v/i1.htm>Crying II</a> Suggests a crying episode.~;
	push @togo, qq~<br><a href=/t/hyp8v/k1.htm>Training</a> Suggests that your unconscious will help you with training (outside of training) for the next few days.~;
	push @togo, qq~<br><a href=/t/hyp8v/m1.htm>Obedience</a> Suggests that your unconscious will help train you to be obedient for the next few days.~;

	push @togo, qq~<br><a href=/t/hyp9v/b1.htm>emails</a> Imagining emailing~;

	push @togo, qq~<br><a href=/t/hyp8v/d1.htm>Suggests writing a fantasy</a>~;
	push @togo, qq~<br><a href=/t/hyp10v/b1.htm>Fantasy I</a> Experience a story~;
	push @togo, qq~<br><a href=/t/hyp10v/c1.htm>Systematic Desensitization I</a> to Jack's touch~ if $id eq "1171642486374";
	push @togo, qq~<br><a href=/t/hyp10v/d1.htm>Systematic Desensitization II</a> to Jack's touch~ if $id eq "1171642486374";
	push @togo, qq~<br><a href=/t/hyp10v/e1.htm>Systematic Desensitization III</a> going slower than II~ if $id eq "1171642486374";
	push @togo, qq~<br><a href=/t/hyp10v/e1.htm>Systematic Desensitization IV</a> continuing to go slow~ if $id eq "1171642486374";
}

push @togo, qq~<p><a href=/t/start/hyppics.htm>Change pictures for the hypnotist</a>. Not recommended.~ if $hyppic;

printonblankerpage(@togo);
exit;

################


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

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

sub printpage {
	my ($fl, $in) = @_;
	chdir("/home12c/sub007/sc13648-GPVH/cp");
	exec "cgi-bin/main.pl" if $fl eq "page" || $fl eq "ownpage";
	open(DATA,"$fl") || open(DATA,"$fl") || gracefulend("There was a problem reading $fl");
	@lines = <DATA>;
	close(DATA);
	foreach (@lines) {
		s/INSERT/$in/go;
		print;
	}
	exit;
}

sub savechangestochr {
	open(DATA,">CPs/$subfolder/$id/chr.txt") || open(DATA,">CPs/$subfolder/$id/chr.txt")  || print "Problem writing to chr for some reason: $!";
	@keys = keys(%info);
	foreach (@keys) {
		$i = $info{$_};
		print DATA "$_=$i\n";
	}
	close(DATA);
	return;
}