#!/usr/bin/perl require "admin/pfade.txt"; if (!$dbpfad) { $dbpfad="$ENV{'SCRIPT_FILENAME'}"; $dbpfad=~s/\/Xandra.cgi//i; } if (!$httppfad) { $httppfad="http://$ENV{'HTTP_HOST'}$ENV{'SCRIPT_NAME'}"; $httppfad=~s/\/Xandra.cgi//i; } if (!$cgipfad) { $cgipfad="http://$ENV{'HTTP_HOST'}$ENV{'SCRIPT_NAME'}"; $cgipfad=~s/\/Xandra.cgi//i; } print "P3P: CP=\"NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM\"\n"; print "Expires: Wed, 11 Nov 1998 11:11:11 GMT\n"; &datum_zeit(); %in = &parsing(); &readcookies(); if ($in{ssl}) { $cgipfad=~s/http\:/https\:/gi; $httppfad=~s/http\:/https\:/gi; } $anzahlbeleidugungen=$COOKIE{xandrabeleidigungen}; $spezialgruppe=$COOKIE{spezialgruppe}; $sid=$COOKIE{sid}; $sound=$COOKIE{sound}; $username=$COOKIE{xandraname}; $userstatus=$COOKIE{xuserstatus}; require "$dbpfad/db/grundeinstellungen.db"; if ($in{input}) { &checkbeleidigung(); } elsif ($in{leerlauf}) { &leerlauf(); } elsif ($in{mute}) { &mute(); } elsif ($in{klopfen}) { $text="klopf, klopf..."; $animation="klopfen.swf"; &output ($text, $animation); } elsif ($in{tipp}) { &name(); } elsif ($in{begruessung}) { &begruessung(); } elsif ($in{pid}) { my $pid; open (PID, "<$dbpfad/db/pid.db"); undef $/; $pid=; close (PID); print "Content-type: text/html; charset=ISO-8859-1\r\n\r\n"; print "pid=$pid"; } else { $scname="spezialgruppe"; $scinhalt=$in{spezial}; &setcookie($scname, $scinhalt); open (PID, "<$dbpfad/db/pid.db"); undef $/; $pid=; close (PID); $format=$in{format}; if ($format eq "large") { $width=150; $height=320; } elsif ($format eq "xlarge") { $width=150; $height=460; } elsif ($format eq "wide") { $width=350; $height=190; } elsif ($format eq "wides") { $width=300; $height=180; } elsif ($format eq "praesentation") { $width=350; $height=159; } else { $width=150; $height=260; } require "$dbpfad/db/smseinstellungen.db"; if ((!$kurzwahl) || (!$keywords) || (!$subkeyword) || (!$preis)) { $smsmodus="off"; } else { $smsmodus=$modus; } print "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; if ($ENV{'HTTP_USER_AGENT'} =~/Robot/i) { &rt(); } else { print "// Wenn Sie dies hier lesen k鰊nen, haben Sie Xandra direkt aufgerufen.
\n", "// Die gute Nachricht ist, Sie wissen das dieser Teil funktioniert :-)
\n", "// Die Schlechte ist, so wird es nichts - Sie m黶sen den Code verwenden, der
\n", "// in der Administration unter \"Einstellungen->Xandra einbinden\" generiert wird!


\n"; print "\n", "document.write('"; } print "", " 2) { print "&beleidigung=1"; } if ($in{cr} eq "off") { print "&cr=off"; } print "&baseurl=$cgipfad/&httpurl=$httppfad/\" />", "", "", "", ""; if (! $in{bg}) { print ""; } print "", " 2) { print "&beleidigung=1"; } if ($in{cr} eq "off") { print "&cr=off"; } print "&baseurl=$cgipfad/&httpurl=$httppfad/\" loop=\"false\" menu=\"false\" quality=\"high\" "; if (! $in{bg}) { print "wmode=\"transparent\" "; } print "bgcolor=\"#$in{bg}\" width=\"$width\" height=\"$height\" name=\"Xandra\" align=\"middle\" type=\"application/x-shockwave-flash\" "; if (!$in{ssl}) { print "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" "; } print "allowScriptAccess=\"always\" />", ""; if ($ENV{'HTTP_USER_AGENT'} !~/Robot/i) { print "')"; } } ############################### sub checkbeleidigung { $input=$in{input}; $input=~tr/[A-Z周腯/[a-z鳇鋆/; $input=~s/[\?\!\.\,\^]//gi; $input=~s/<.*?>//gs; $input=~s/^\s//; $input=~s/\s$//; $input=~s/\(/%%ka%%/gi; $input=~s/\)/%%kz%%/gi; require "$dbpfad/db/beleidigt.db"; if ($beleidigungsmodus ne "off") { if ($anzahlbeleidugungen > 2) { print "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; print "animation=&output=&beleidigung=1"; } else { @beleidigungenText = split(/\x20/, $input); foreach $test (@beleidigungenText) { chomp($test); $test=~s/[^a-zA-Z漩周]//gi; push @beleidigungenSchluessel, $test; } $treffer=0; open (BELEIDIGUNGEN, "<$dbpfad/db/beleidigungen.db"); flock(BELEIDIGUNGEN, 1); while ($line = ) { chomp($line); $line=~s/^\s//i; $line=~s/\s$//i; foreach $beleidigungentest (@beleidigungenSchluessel) { chomp($beleidigungentest); if ($line eq $beleidigungentest) { $treffer++; $beleidigung="$line"; last; } } } close(BELEIDIGUNGEN); } if (($treffer > 0) && ($beleidigungsmodus eq "on")) { $anzahlbeleidugungen=$anzahlbeleidugungen+1; $scname="xandrabeleidigungen"; $scinhalt=$anzahlbeleidugungen; &setcookie($scname, $scinhalt); if ($anzahlbeleidugungen > 3) { print "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; print "animation=&output=&beleidigung=1"; } elsif ($anzahlbeleidugungen == 3) { $text="$beleidigungstext3"; $text=~s/:INPUT:/$beleidigung/gi; $sekunden=$beleidigungsekunden3; $mp3=$beleidigungmp33; if ($beleidigungpose3) { $animation="$beleidigungpose3.swf"; } else { $animation="abweisend.swf"; } $url="$beleidigungurl3"; $target="$beleidigungtarget3"; $urlsekunden=$beleidigungurlsekunden3; &output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden); } elsif ($anzahlbeleidugungen == 2) { $text="$beleidigungstext2"; $text=~s/:INPUT:/$beleidigung/gi; $sekunden=$beleidigungsekunden2; $mp3=$beleidigungmp32; if ($beleidigungpose2) { $animation="$beleidigungpose2.swf"; } else { $animation="verneinend.swf"; } &output ($text, $animation, $sekunden, $mp3); } elsif ($anzahlbeleidugungen == 1) { $text="$beleidigungstext1"; $text=~s/:INPUT:/$beleidigung/gi; $sekunden=$beleidigungsekunden1; $mp3=$beleidigungmp31; if ($beleidigungpose1) { $animation="$beleidigungpose1.swf"; } else { $animation="aufgepasst.swf"; } &output ($text, $animation, $sekunden, $mp3); } } elsif (($treffer > 0) && ($beleidigungsmodus eq "ignorieren")) { &tippplugins(); } elsif ($anzahlbeleidugungen < 3) { &preplugins(); } } else { &preplugins(); } } sub preplugins { open (PRE, "<$dbpfad/db/pre_plugins.db"); flock(PRE, 1); @prelines =
;
	close(PRE);

	$text="";
	$animation="";
	$scname="";
	$scinhalt="";
	$scdauer="";

	$preplugincount=0;

	foreach $preline (@prelines)
		{
		if ($preplugincount < 1)
			{
			chomp($preline);

			($plugin, $pluginname)=split(/\|/, $preline);

			use LWP::UserAgent;
			$ua = new LWP::UserAgent;

			$ua->timeout(5);
			$ua->agent('Xandra');
			$req = new HTTP::Request GET => "$plugin?input=$in{input}&sid=$sid&spezial=$in{spezial}";
			$res = $ua->request($req);

			$echo=$res->content;
			eval ($echo);

			if (($text) && ($animation))
				{
				$preplugincount++;
				}
			}
		}

	if (($text) && ($animation))
		{
		if (($scname) && ($scinhalt))
			{
			&setcookie($scname, $scinhalt, $scdauer);
			}

		$dbinput=$in{input};
		$dbinput=~s/<.*?>//gs;

		open (POSITIV, "+<$dbpfad/db/positiv.db");
		flock(POSITIV, 2);
		seek(POSITIV, 0, 2);
		print POSITIV "$^T|$ndate|$dbinput|extern|extern|$text|extern|\n";
		close(POSITIV);

		open (PS, "<$dbpfad/db/positivstats.db");
		flock(PS, 1);
		$positivstats=;
		close(PS);

		if ($positivstats)
			{
			$positivstats=$positivstats+1;
			open (PS, ">$dbpfad/db/positivstats.db");
			flock(PS, 2);
			print PS "$positivstats";
			close(PS);
			}

		&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
		}
	else
		{
		&run();
		}
	}
sub run
	{
	open (KEYWORDS, "<$dbpfad/db/keywords.db");
	flock(KEYWORDS, 1);
	@keywordlines = ;
	close(KEYWORDS);

	open (GRUPPEN, "<$dbpfad/db/gruppen.db");
	flock(GRUPPEN, 1);
	@gruppenlines = ;
	close(GRUPPEN);

	&checkname();
	}
sub begruessung
	{
	if (!$userstatus)
		{
		$scname="xuserstatus";
		$scinhalt="zaehlen";
		$scdauer="90";
		&setcookie($scname, $scinhalt, $scdauer);
		}
	elsif ($userstatus eq "zaehlen")
		{
		open (US, "<$dbpfad/db/userstats.db");
		flock(US, 1);
		$xuser = ;
		close(US);

		if ($xuser)
			{
			$xuser=$xuser+1;
			open (US, ">$dbpfad/db/userstats.db");
			flock(US, 2);
			print US "$xuser";
			close(US);
			}

		$scname="xuserstatus";
		$scinhalt="gezaehlt";
		$scdauer="90";
		&setcookie($scname, $scinhalt, $scdauer);
		}
	elsif ($userstatus eq "gezaehlt")
		{
		open (AS, "<$dbpfad/db/aufrufestats.db");
		flock(AS, 1);
		$xaufrufe = ;
		close(AS);

		if ($xaufrufe)
			{
			$xaufrufe=$xaufrufe+1;
			open (AS, ">$dbpfad/db/aufrufestats.db");
			flock(AS, 2);
			print AS "$xaufrufe";
			close(AS);
			}
		}

	$lastmeeting=$COOKIE{xandrameeting};

	$scname="xandrameeting";
	$scinhalt=$^T;
	$scdauer=90;
	&setcookie($scname, $scinhalt, $scdauer);

	if ($in{spezial})
		{
		$spezial=$in{spezial};
		$spezial=~s/[^0-9]//gi;

		open (GRUPPEN, "<$dbpfad/db/gruppen.db");
		flock(GRUPPEN, 1);
		@gruppenlines = ;
		close(GRUPPEN);

		foreach $line (@gruppenlines)
			{
			chomp($line);

			@gruppe=split(/\|/, $line);

			if (($gruppe[0] eq $spezial) && ($gruppe[2]) && ($gruppe[7]))
				{
				$gruppenpose="$gruppe[2]";
				$gruppenurl="$gruppe[3]";
				$gruppentarget="$gruppe[4]";
				$gruppenbegruessung="$gruppe[7]";
				$gruppensekunden="$gruppe[8]";
				$gruppenmp3="$gruppe[9]";

				last;
				}
			}
		}
	else
		{
		$spezial="";
		}

	if ($in{sid})
		{
		$sid=$in{sid};
		$sid=~s/undefined//gi;
		}
	else
		{
		$sid="";
		}

	$scname="sid";
	$scinhalt=$sid;
	&setcookie($scname, $scinhalt);

	if ($gruppenbegruessung)
		{
		$text="$gruppenbegruessung";
		$sekunden=$gruppensekunden;
		$mp3=$gruppenmp3;

		if ($gruppenpose)
			{
			$animation="$gruppenpose.swf";
			}
		else
			{
			$animation="winken.swf";
			}

		if ($gruppenurl)
			{
			$url="$gruppenurl";
			$target="$gruppentarget";
			$urlsekunden="auto";
			}

		&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
		}
	elsif (!$lastmeeting)
		{
		$text="$begruessung";
		$sekunden=$begruessungsekunden;
		$mp3=$begruessungmp3;

		if ($begruessungpose)
			{
			$animation="$begruessungpose.swf";
			}
		else
			{
			$animation="winken.swf";
			}

		&output ($text, $animation, $sekunden, $mp3);
		}
	elsif ($lastmeeting > $^T-3600)
		{
		&name();
		}
	elsif ($lastmeeting > $^T-172800)
		{
		$text="$begruessung2";
		$sekunden=$begruessung2sekunden;
		$mp3=$begruessungmp32;

		if ($begruessung2pose)
			{
			$animation="$begruessung2pose.swf";
			}
		else
			{
			$animation="zustimmend.swf";
			}

		&output ($text, $animation, $sekunden, $mp3);
		}
	elsif ($lastmeeting < $^T-172800)
		{
		$text="$begruessung3";
		$sekunden=$begruessung3sekunden;
		$mp3=$begruessungmp33;

		if ($begruessung3pose)
			{
			$animation="$begruessung3pose.swf";
			}
		else
			{
			$animation="winken.swf";
			}
		&output ($text, $animation, $sekunden, $mp3);
		}
	}
###############################
sub main
	{
	my($spezialoff)=@_;

	if ($spezialoff > 0)
		{
		$spezial="";
		}
	else
		{
		$spezial=$in{spezial};
		}

	$treffer=0;
	$zeile=0;

	foreach $line (@keywordlines)
		{
		$zeile++;
		chomp($line);

		@keywords=split(/\|/, $line);

		if (($keywords[7] ne 2) && ((($spezial) && ($spezial eq $keywords[7]) && ($keywords[8] eq "spezial")) || ((!$spezial) && ($keywords[8] ne "spezial"))))
			{
			$w=0;

			@words=split(/,/, $keywords[1]);

			foreach $test (@words)
				{
				$w++;

				chomp($test);
				$test=~s/^\s//g;
				$test=~s/\s$//g;
				$test=~s/\(/%%ka%%/gi;
				$test=~s/\)/%%kz%%/gi;
				$test=~s/[\+\*]/ /g;
				$test=~s/  / /g;
				$test=~tr/[A-Z周腯/[a-z鳇鋆/;

				@multibel=split(/%%%/, $test);

				$testlaenge=length($test);
				$testlaenge=$testlaenge-3 if ($test=~/%%%/i);

				if ($testlaenge < length($input))
					{
					$prozent=$testlaenge*100/length($input);
					}
				elsif ($testlaenge == length($input))
					{
					$prozent=100;
					}
				else
					{
					$prozent=length($input)*100/length($test);
					}

				$prozent=sprintf("%.0f", $prozent);

				$ist=0;
				$soll=@multibel;
				foreach $multi (@multibel)
					{
					chomp($multi);
					$multi=~s/^\s//g;
					$multi=~s/\s$//g;

					if ($input=~/$multi/i)
						{
						$ist++;
						}
					}

				if ((($ist == $soll) && ($prozent > 49)) || (($ist == $soll) && ($keywords[2]=~/:INPUT:/i) && ($prozent > 0)))
					{
					push @tmp, "$zeile|$prozent|$test|";

					$treffer++;
					}
				}
			}
		}

	if ($treffer > 0)
		{
		@sortiert = map $_->[0],sort {$b->[1] <=> $a->[1]}map [$_, (split /\|/)[1]], @tmp;

		foreach $best (@sortiert)
			{
			$first++;

			if ($first == 1)
				{
				chomp ($best);
				($bestline,$genauigkeit,$test)=split(/\|/, $best);
				last;
				}
			}

		foreach $line (@keywordlines)
			{
			$nummer++;

			if ($nummer == $bestline)
				{
				chomp($line);

				@keywords=split(/\|/, $line);

				@mp3s = split/, /,$keywords[10];
				$mp3=$mp3s[0];

				if ($keywords[2] =~/%%%/)
					{
					@antwort = split/%%%/,$keywords[2];
					$anzahl=@antwort;
					$zufall=int(rand($anzahl));

					$keywords[2]=$antwort[$zufall];

					$mp3=$mp3s[$zufall];
					}

				$keywords[2]=~s/:INPUT:/$test/gi;
				$text=$keywords[2];
				$text=~s/%%%/ /gi;

				if ($keywords[4])
					{
					$url="$keywords[4]";
					$url=~s/:INPUT:/$test/gi;
					$target="$keywords[5]";

					$urlsekunden="$keywords[9]";
					}

				$animation="$keywords[3].swf";

				$keywordsid="$keywords[0]";
				$keywords="$keywords[1]";
				$sekunden=$keywords[6];

				last;
				}
			}

		&positiv ($keywordsid, $keywords, $text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden, $genauigkeit);
		}
	else
		{
		if (($spezial) && ($spezialoff < 1))
			{
			$spezialoff=1;
			&main($spezialoff);
			}
		else
			{
			&postplugins();
			}
		}
	}
sub postplugins
	{
	open (POST, "<$dbpfad/db/post_plugins.db");
	flock(POST, 1);
	@postlines = ;
	close(POST);

	$text="";
	$animation="";
	$scname="";
	$scinhalt="";
	$scdauer="";

	$postplugincount=0;

	foreach $postline (@postlines)
		{
		if ($postplugincount < 1)
			{
			chomp($postline);

			($plugin, $pluginname)=split(/\|/, $postline);

			use LWP::UserAgent;
			$ua = new LWP::UserAgent;

			$ua->timeout(5);
			$ua->agent('Xandra');
			$req = new HTTP::Request GET => "$plugin?input=$in{input}&sid=$sid&spezial=$in{spezial}";
			$res = $ua->request($req);

			$echo=$res->content;
			eval ($echo);

			if (($text) && ($animation))
				{
				$postplugincount++;
				}
			}
		}

	if (($text) && ($animation))
		{
		if (($scname) && ($scinhalt))
			{
			&setcookie($scname, $scinhalt, $scdauer);
			}

		$dbinput=$in{input};
		$dbinput=~s/<.*?>//gs;

		open (POSITIV, "+<$dbpfad/db/positiv.db");
		flock(POSITIV, 2);
		seek(POSITIV, 0, 2);
		print POSITIV "$^T|$ndate|$dbinput|extern|extern|$text|extern|\n";
		close(POSITIV);

		open (PS, "<$dbpfad/db/positivstats.db");
		flock(PS, 1);
		$positivstats=;
		close(PS);

		if ($positivstats)
			{
			$positivstats=$positivstats+1;
			open (PS, ">$dbpfad/db/positivstats.db");
			flock(PS, 2);
			print PS "$positivstats";
			close(PS);
			}

		&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
		}
	else
		{
		&negativ();
		}
	}
sub positiv
	{
	my ($keywordsid, $keywords, $text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden, $genauigkeit)=@_;
	$dbinput=$in{input};
	$dbinput=~s/<.*?>//gs;

	$text=~s/:NAME:/$username/gi;
	$text=~s/:WOCHENTAG:/$tag/gi;
	$text=~s/:MONATSTAG:/$mday./gi;
	$text=~s/:MONATSNAME:/$monat/gi;
	$text=~s/:MONAT:/$mon./gi;
	$text=~s/:STUNDE:/$hour/gi;
	$text=~s/:MINUTE:/$min/gi;

	open (POSITIV, "+<$dbpfad/db/positiv.db");
	flock(POSITIV, 2);
	seek(POSITIV, 0, 2);
	print POSITIV "$^T|$ndate|$dbinput|$keywordsid|$keywords|$text|$genauigkeit|$url|$mp3|\n";
	close(POSITIV);

	if ($userstatus eq "gezaehlt")
		{
		open (PS, "<$dbpfad/db/positivstats.db");
		flock(PS, 1);
		$positivstats=;
		close(PS);

		if ($positivstats)
			{
			$positivstats=$positivstats+1;
			open (PS, ">$dbpfad/db/positivstats.db");
			flock(PS, 2);
			print PS "$positivstats";
			close(PS);
			}
		}

	&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
	}
sub checkname
	{
	open (NAMEN, "<$dbpfad/db/namen.db");
	flock(NAMEN, 1);
	@namensliste=;
	close(NAMEN);

	$fragenachnamen=$COOKIE{xandranamefrage};

	$treffer=0;

	if (($input=~/bin ich/i) || ($input=~/hei遝 ich/i) || ($input=~/heisse ich/i) || ($input=~/heise ich/i) || ($input=~/mein name/i) || ($input=~/ich bin/i) || ($input=~/ich heisse/i) || ($input=~/ich hei遝/i) || ($input=~/ich heise/i) || ($input=~/mein name/i))
		{
		@suchText = split(/\x20/, $input);

		foreach $test (@suchText)
			{
			chomp($test);

			if (($test=~/\S{2,}/) && ($test ne "das") && ($test ne "bin") && ($test ne "ich") && ($test ne "heisse") && ($test ne "hei遝") && ($test ne "mein") && ($test ne "name") && ($test ne "ist"))
				{
				push @nameSchluessel, $test;
				}
			}

		foreach $name (@namensliste)
			{
			chomp($name);
			$name=~s/^\s//i;
			$name=~s/\s$//i;

			$matchname=$name;
			$matchname=~tr/[A-Z周腯/[a-z鳇鋆/;

			foreach $nametest (@nameSchluessel)
				{
				chomp($nametest);

				if ($matchname eq $nametest)
					{
					$scname="xandraname";
					$scinhalt=$name;
					$scdauer=90;
					&setcookie($scname, $scinhalt, $scdauer);

					$text="$vorstellung";
					$text=~s/:NAME:/$name/gi;
					$sekunden=$vorstellungsekunden;
					$mp3=$vorstellungmp3;

					if ($vorstellungpose)
						{
						$animation="$vorstellungpose.swf";
						}
					else
						{
						@zAni=("zustimmend.swf", "gruss.swf", "winken.swf", "tipp.swf");
						$anzahl=@zAni;
						$zufall=int(rand($anzahl));
						$animation="$zAni[$zufall]";
						}

					&output ($text, $animation, $sekunden, $mp3);

					$treffer++;

					last;
					}
				}
			}
		}
	else
		{
		foreach $name (@namensliste)
			{
			chomp($name);
			$name=~s/^\s//i;
			$name=~s/\s$//i;

			$matchname=$name;
			$matchname=~tr/[A-Z周腯/[a-z鳇鋆/;

			if ($input eq $matchname)
				{
				$scname="xandraname";
				$scinhalt=$name;
				$scdauer=90;
				&setcookie($scname, $scinhalt, $scdauer);

				$text="$vorstellung";
				@zAni=("zustimmend.swf", "gruss.swf", "winken.swf", "tipp.swf");
				$anzahl=@zAni;
				$zufall=int(rand($anzahl));
				$animation="$zAni[$zufall]";
				$sekunden=$vorstellungsekunden;
				$mp3=$vorstellungmp3;

				$text=~s/:NAME:/$name/gi;

				&output ($text, $animation, $sekunden, $mp3);

				$treffer++;
				last;
				}
			}
		}

	if ($treffer < 1)
		{
		&rechnen();
		}
	}
sub rechnen
	{
	$rechinput=$in{input};
	$rechinput=~s/mal/\*/gi;
	$rechinput=~s/geteilt durch/\//gi;
	$rechinput=~s/durch/\//gi;
	$rechinput=~s/plus/+/gi;
	$rechinput=~s/minus/-/gi;
	$rechinput=~s/hoch/\*\*/gi;
	$rechinput=~s/wurzel/\|/gi;
	$rechinput=~s/\^/\*\*/gi;
	$rechinput=~s/x/\*/gi;
	$rechinput=~s/\:/\//gi;
	$rechinput=~s/pi/3.14159265/gi;
	$rechinput=~s/[^0-9\+\-\*\/\(\)\,\.\|sqrt |cos |exp |sin |oct |hex |log ]//gi;
	$rechinput=~s/,/./gi;
	$rechinput=~s/^\*//i;
	$rechinput=~s/^\+//i;
	$rechinput=~s/^\///i;
	$rechinput=~s/^\.//i;
	$rechinput=~s/\*$//i;
	$rechinput=~s/\+$//i;
	$rechinput=~s/\-$//i;
	$rechinput=~s/\/$//i;
	$rechinput=~s/^\.$//i;
	$rechinput=~s/\|/sqrt /i;

	$treffer=0;

	if (($rechinput=~/[0-9]/) && (($rechinput=~/\-/) || ($rechinput=~/\+/) || ($rechinput=~/\*/) || ($rechinput=~/\//) || ($rechinput=~/sqrt|cos|exp|sin|oct|hex|log/)))
		{
		$ergebnis = eval ($rechinput);

		$rechinput=~s/\*\*/ hoch /g;
		$rechinput=~s/sqrt/ Wurzel aus /g;
		$rechinput=~s/cos/ Cosinus aus /g;
		$rechinput=~s/exp/ Exponentialwert aus /g;
		$rechinput=~s/sin/ Sinus aus /g;
		$rechinput=~s/oct|hex/ Dezimalwert aus /g;
		$rechinput=~s/log/ nat. Logarithmus aus /g;
		$text="$rechinput=$ergebnis";
		@zAni=("zeigend.swf", "praesentieren.swf");
		$anzahl=@zAni;
		$zufall=int(rand($anzahl));
		$animation="$zAni[$zufall]";

		&output ($text, $animation);

		$treffer++;
		}

	if ($treffer < 1)
		{
		&main();
		}
	}
sub negativ
	{
	$dbinput=$in{input};
	$dbinput=~s/<.*?>//gs;

	if ($in{spezial})
		{
		foreach $gruppenline (@gruppenlines)
			{
			chomp($gruppenline);

			@gruppe=split(/\|/, $gruppenline);

			if ($in{spezial} == $gruppe[0])
				{
				$gruppenname=$gruppe[1];
				last;
				}
			}
		}

	open (NEGATIV, "+<$dbpfad/db/negativ.db");
	flock(NEGATIV, 2);
	seek(NEGATIV, 0, 2);
	print NEGATIV "$^T|$ndate|$dbinput|$gruppenname|\n";
	close(NEGATIV);

	if ($userstatus eq "gezaehlt")
		{
		open (NS, "<$dbpfad/db/negativstats.db");
		flock(NS, 1);
		$negativstats=;
		close(NS);

		if ($negativstats)
			{
			$negativstats=$negativstats+1;
			open (NS, ">$dbpfad/db/negativstats.db");
			flock(NS, 2);
			print NS "$negativstats";
			close(NS);
			}
		}

	if ($keininfo)
		{
		if ($spezial)
			{
			$spezialgruppe=$spezial;
			}

		open (TIPPS, "<$dbpfad/db/tipps.db");
		flock(TIPPS, 1);
		@tipps = ;
		close (TIPPS);

		foreach $tippsline (@tipps)
			{
			chomp($tippsline);

			@tipp=split(/\|/, $tippsline);

			if (($tipp[6] ne 2) && ((($spezialgruppe) && ($spezialgruppe eq $tipp[6])) || ((!$spezialgruppe) && ($tipp[7] ne "spezial")) || ($tipp[7] ne "spezial")))
				{
				push @gueltigetipps, $tippsline;
				$zeilen++;
				}
			}

		$random=int(rand($zeilen));

		$i1=0;
		$i2=0;

		foreach $line (@gueltigetipps)
			{
			chomp($line);

			($tippid, $tipp, $pose, $url, $target, $urlsekunden, $gruppe, $spezial, $sekunden, $mp3)=split(/\|/ , $line);

			if (($tippid) && ($i1 == $random))
				{
				$i2++;

				if (length($dbinput) > 30)
					{
					$dbinput=substr ($dbinput, 0, 30);
					$dbinput="$dbinput...";
					}

				$keininfo=~s/:INPUT:/$dbinput/gi;

				if ($keininfo=~/%%%/i)
					{
					@antwort = split(/%%%/,$keininfo);
					$anzahl=@antwort;
					$zufall=int(rand($anzahl));

					$keininfo=$antwort[$zufall];
					}

				$text="$keininfo $tipp";
				$animation="$pose.swf";
				$url=~s/:INPUT:/$dbinput/gi;

				&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
				last;
				}
			$i1++;
			}
		}

	if ($i2 < 1)
		{
		if (length($dbinput) > 30)
			{
			$dbinput=substr ($dbinput, 0, 30);
			$dbinput="$dbinput...";
			}

		$keintipp=~s/:INPUT:/$dbinput/gi;
		@mp3s = split/, /,$keintippmp3;
		$mp3=$mp3s[0];

		if ($keintipp=~/%%%/i)
			{
			@antwort = split(/%%%/,$keintipp);
			$anzahl=@antwort;
			$zufall=int(rand($anzahl));

			$keintipp=$antwort[$zufall];
			$mp3=$mp3s[$zufall];
			}

		$text="$keintipp";
		$sekunden=$keintippsekunden;

		if ($keintipppose)
			{
			$animation="$keintipppose.swf";
			}
		else
			{
			$animation="ratlos.swf";
			}

		if ($keintippurl)
			{
			$url="$keintippurl";
			$url=~s/:INPUT:/$dbinput/gi;
			$target="$keintipptarget";
			$urlsekunden="$keintippurlsekunden";
			}
		&output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden);
		}
	}
sub leerlauf
	{
	opendir(DIRHANDLE, "$dbpfad/animationen/leerlauf");
	@allfiles = readdir(DIRHANDLE);
	closedir DIRHANDLE;

	foreach $file (@allfiles)
		{
		chomp($file);

		if ($file=~/swf/i)
			{
			$anzahl++;
			}
		}
	$random=int(rand($anzahl));

	$i=0;

	foreach $file1 (@allfiles)
		{
		chomp($file1);

		if ($file1=~/swf/i)
			{
			if ($i == $random)
				{
				$animation="leerlauf/$file1";
				&output ($text, $animation);
				last;
				}
			$i++;
			}
		}
	}
sub name
	{
	$lastmeeting=$COOKIE{xandrameeting};
	$fragenachnamen=$COOKIE{xandranamefrage};

	if (($namefrage) && ($lastmeeting) && (!$username) && ((!$fragenachnamen) || ($fragenachnamen < $^T-300)))
		{
		$scname="xandranamefrage";
		$scinhalt=$^T;
		&setcookie($scname, $scinhalt);

		$text="$namefrage";
		$sekunden=$namefragesekunden;
		$mp3=$namefragemp3;

		if ($namefragepose)
			{
			$animation="$namefragepose.swf";
			}
		else
			{
			$animation="gruss.swf";
			}

		&output ($text, $animation, $sekunden, $mp3);
		}
	else
		{
		&sms();
		}
	}
sub sms
	{
	require "$dbpfad/db/smseinstellungen.db";

	$lastsms=$COOKIE{xandralastsms};

	$lebenszeit=$lebensdauer*60;

	$smsanzahl=0;

	open (SMS, "<$dbpfad/db/sms.db");
	flock (SMS, 1);
	@lines = ;
	close (SMS);

	open (SMS, ">$dbpfad/db/sms.db");
	flock (SMS, 2);

	foreach $line (@lines)
		{
		chomp($line);

		@data_set=split(/\|/, $line);

		if ($data_set[2] < $^T-$lebenszeit)
			{
			$del++;
			}
		else
			{
			print SMS "$line\n";

			if ($lastsms ne $data_set[2])
				{
				push @smsliste, $line;
				$smsanzahl++;
				}
			}
		}
	close (SMS);

	if ($smsanzahl > 0)
		{
		$smsrandom=int(rand($smsanzahl));

		$i=0;

		foreach $smsline (@smsliste)
			{
			#chomp($smsline);

			($smstext, $absender, $zeitstempel)=split(/\|/ , $smsline);

			if (($i == $smsrandom) && ($lastsms ne $zeitstempel))
				{
				if ($smsueberleitung)
					{
					$text="$smsueberleitung $smstext";
					}
				else
					{
					$text="Wow, eine SMS an mich! Der Absender schreibt:
$smstext"; } if ($smspose) { $animation="$smspose.swf"; } else { $animation="handy.swf"; } $mp3=$smsmp3; $scname="xandralastsms"; $scinhalt=$zeitstempel; &setcookie($scname, $scinhalt); &output ($text, $animation, $sekunden, $mp3); last; } $i++; } } else { &tippplugins(); } } sub tippplugins { open (TIPP, "<$dbpfad/db/tipp_plugins.db"); flock(TIPP, 1); @tipplines = ; close(TIPP); $text=""; $animation=""; $scname=""; $scinhalt=""; $scdauer=""; $tippplugincount=0; foreach $tippline (@tipplines) { if ($tippplugincount < 1) { chomp($tippline); ($plugin, $pluginname)=split(/\|/, $tippline); use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->timeout(5); $ua->agent('Xandra'); $req = new HTTP::Request GET => "$plugin?sid=$sid&spezial=$spezial"; $res = $ua->request($req); $echo=$res->content; eval ($echo); if (($text) && ($animation)) { $tippplugincount++; } } } if (($text) && ($animation)) { if (($scname) && ($scinhalt)) { &setcookie($scname, $scinhalt, $scdauer); } &output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden); } else { &tipp(); } } sub tipp { $lasttipp=$COOKIE{xandralasttipp}; if ($spezial) { $spezialgruppe=$spezial; } open (TIPPS, "<$dbpfad/db/tipps.db"); flock(TIPPS, 1); @tipps = ; close (TIPPS); $passt=0; foreach $tippsline (@tipps) { chomp($tippsline); @tipp=split(/\|/, $tippsline); if (($tipp[0] ne $lasttipp) && ($tipp[6] ne 2) && ((($spezialgruppe) && ($spezialgruppe eq $tipp[6])) || ((!$spezialgruppe) && ($tipp[7] ne "spezial")))) { $passt++; push @gueltigetipps, $tippsline; } } if ($passt < 1) { foreach $tippsline (@tipps) { chomp($tippsline); @tipp=split(/\|/, $tippsline); if (($tipp[0] ne $lasttipp) && ($tipp[6] ne 2) && ($tipp[7] ne "spezial")) { push @gueltigetipps, $tippsline; } } } $zeilen=@gueltigetipps; $random=int(rand($zeilen)); $i1=0; $treffer=0; foreach $line (@gueltigetipps) { chomp($line); @tipp=split(/\|/ , $line); if (($tipp[0]) && ($i1 == $random)) { $treffer++; $scname="xandralasttipp"; $scinhalt=$tipp[0]; &setcookie($scname, $scinhalt); $text="$tipp[1]"; $animation="$tipp[2].swf"; $sekunden=$tipp[8]; $mp3=$tipp[9]; if ($tipp[3]) { $url="$tipp[3]"; $target="$tipp[4]"; $urlsekunden="$tipp[5]"; } &output ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden); last; } $i1++; } if ($treffer < 1) { &leerlauf(); } } sub output { my ($text, $animation, $sekunden, $mp3, $url, $target, $urlsekunden)=@_; $text=~s/:NAME:/$username/gi; $text=~s/:SID:/$sid/gi; $text=~s/:WOCHENTAG:/$tag/gi; $text=~s/:MONATSTAG:/$mday./gi; $text=~s/:MONATSNAME:/$monat/gi; $text=~s/:MONAT:/$mon./gi; $text=~s/:STUNDE:/$hour/gi; $text=~s/:MINUTE:/$min/gi; $text=~s/\\<\/b\>//gi; $text=~s/ / /gi; $text=~s/ \,/\,/gi; $text=~s/ \./\./gi; $text=~s/ \!/\!/gi; $text=~s/ \?/\?/gi; if ($mp3) { $mp3datei="$httppfad/multimedia/$mp3"; } $sekunden=~s/[^0-9]//gi; $urlsekunden=~s/[^0-9]//gi; $sekunden=sprintf("%.0f", length($text)*0.1) if ($sekunden < 1); $sekunden=5 if ($sekunden < 5); $text=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; print "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; print "animation=
&outtxt=$text&sekunden=$sekunden"; if ($sound ne "off") { print "&mp3=$mp3datei"; } $urlsekunden=$sekunden-1 if (($urlsekunden < 1) || (($urlsekunden => $sekunden) && ($url))); $url=~s/:SID:/$sid/gi; $url=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; if (($userstatus eq "gezaehlt") && ($url)) { open (LS, "<$dbpfad/db/linkstats.db"); flock(LS, 1); $linkstats=; close(LS); if ($linkstats) { $linkstats=$linkstats+1; open (LS, ">$dbpfad/db/linkstats.db"); flock(LS, 2); print LS "$linkstats"; close(LS); } } print "&url=$url&target=$target&urlsekunden=$urlsekunden"; } sub mute { $scname="sound"; if ($sound eq "off") { $scinhalt=on; $animation="tipp.swf"; } else { $scinhalt=off; $animation="ratlos.swf"; } $scdauer=90; &setcookie($scname, $scinhalt, $scdauer); $text="Sound $scinhalt"; &output ($text, $animation); } sub setcookie { my ($scname, $scinhalt, $scdauer)=@_; if ($scdauer) { $gmt=gmtime(time()+$scdauer*24*3600)." GMT"; print "Set-Cookie: $scname=$scinhalt; expires=$gmt;\n"; } else { print "Set-Cookie: $scname=$scinhalt;\n"; } } sub readcookies { foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { ($rcname, $rcinhalt) = split(/=/); $COOKIE{$rcname}=$rcinhalt; } } sub rt { $rt=pack ("C*", 77, 105, 116, 32, 100, 101, 109, 32, 88, 97, 110, 100, 114, 97, 45, 67, 104, 97, 116, 66, 111, 116, 32, 104, 97, 98, 101, 110, 32, 83, 105, 101, 32, 105, 109, 32, 72, 97, 110, 100, 117, 109, 100, 114, 101, 104, 101, 110, 32, 101, 105, 110, 101, 110, 32, 118, 105, 114, 116, 117, 101, 108, 108, 101, 110, 32, 77, 111, 100, 101, 114, 97, 116, 111, 114, 32, 102, -4, 114, 32, 73, 104, 114, 101, 32, 72, 111, 109, 101, 112, 97, 103, 101, 44, 32, 100, 105, 101, 115, 101, 114, 32, 118, 111, 108, 108, 97, 117, 116, 111, 109, 97, 116, 105, 115, 99, 104, 101, 32, 67, 104, 97, 116, 45, 66, 111, 116, 32, 107, 97, 110, 110, 32, 73, 104, 114, 101, 32, 66, 101, 115, 117, 99, 104, 101, 114, 32, 117, 110, 100, 32, 75, 117, 110, 100, 101, 110, 32, 50, 52, 32, 83, 116, 117, 110, 100, 101, 110, 32, 97, 109, 32, 84, 97, 103, 32, 98, 101, 116, 114, 101, 117, 101, 110, 44, 32, 97, 108, 115, 32, 111, 98, 32, 115, 105, 99, 104, 32, 101, 105, 110, 32, 101, 99, 104, 116, 101, 114, 32, 77, 105, 116, 97, 114, 98, 101, 105, 116, 101, 114, 32, 97, 117, 102, 32, 73, 104, 114, 101, 114, 32, 72, 111, 109, 101, 112, 97, 103, 101, 32, 101, 105, 110, 113, 117, 97, 114, 116, 105, 101, 114, 116, 32, 104, 97, 116, 46, 32, 77, 101, 104, 114, 32, 73, 110, 102, 111, 114, 109, 97, 116, 105, 111, 110, 101, 110, 32, 101, 114, 104, 97, 108, 116, 101, 110, 32, 83, 105, 101, 32, 117, 110, 116, 101, 114, 58, 32, 60, 97, 32, 104, 114, 101, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 120, 97, 110, 100, 114, 97, 45, 99, 104, 97, 116, 98, 111, 116, 46, 100, 101, 34, 62, 88, 97, 110, 100, 114, 97, 45, 83, 111, 102, 116, 119, 97, 114, 101, 44, 32, 67, 104, 97, 116, 45, 66, 111, 116, 44, 32, 67, 104, 97, 116, 98, 111, 116, 60, 47, 97, 62, 60, 98, 114, 62, 60, 98, 114, 62); print "$rt"; } sub parsing { my($i, $key, $val, %in, @in, $in); 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 plus's 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; $val =~ s/%(..)/pack("c",hex($1))/ge; #Some servers need it doubly, why also always $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/<.*?>.*?<.*?>//g; $val =~ s/<.*?>//g; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple sep $in{$key} .= $val; } %in; } sub datum_zeit { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon=$mon+1; $year=1900+$year; $monat="Januar" if ($mon==1); $monat="Februar" if ($mon==2); $monat="M鋜z" if ($mon==3); $monat="April" if ($mon==4); $monat="Mai" if ($mon==5); $monat="Juni" if ($mon==6); $monat="Juli" if ($mon==7); $monat="August" if ($mon==8); $monat="September" if ($mon==9); $monat="Oktober" if ($mon==10); $monat="November" if ($mon==11); $monat="Dezember" if ($mon==12); $tag="Sonntag" if ($wday==0); $tag="Montag" if ($wday==1); $tag="Dienstag" if ($wday==2); $tag="Mittwoch" if ($wday==3); $tag="Donnerstag" if ($wday==4); $tag="Freitag" if ($wday==5); $tag="Samstag" if ($wday==6); $min="0$min" if ($min < 10); $hour="0$hour" if ($hour < 10); $mon="0$mon" if ($mon < 10); $mday="0$mday" if ($mday < 10); $ndate = "$mday.$mon.$year - $hour:$min"; $datcheck = "$year$mon$mday"; }