From 630af0ed6c0af69c7df2e45aef7a87722a3c00c0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:47 +0200 Subject: tagging ychat-perl-legacy --- 0.4.6/main2.pl | 594 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 594 insertions(+) create mode 100644 0.4.6/main2.pl (limited to '0.4.6/main2.pl') diff --git a/0.4.6/main2.pl b/0.4.6/main2.pl new file mode 100644 index 0000000..36a0012 --- /dev/null +++ b/0.4.6/main2.pl @@ -0,0 +1,594 @@ +#!/usr/bin/perl -w + +# yChat - Copyright by Paul C. Bütow + +use CGI; +$q = new CGI; +require config; +print + $q->header(); + +##################################### +##WELCHE SUB MUß AUSGEFÜHRT WERDEN?## +##################################### + +$var = $q->param("var"); +if ($var eq "list_alias_html") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + &list_alias_html; +} elsif ($var eq "alias_html") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + $tmp = $q->param("tmp"); + &alias_html; +} elsif ($var eq "edit_profile_html") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + $room = $q->param("room"); + &edit_html("edit_profile_html"); +} elsif ($var eq "edit_options_html") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + $room = $q->param("room"); + $col = $q->param("col"); + $secol = $q->param("secol"); + &edit_html("edit_options_html"); +} elsif ($var eq "gb_html") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + &gb_html; +} elsif ($var eq "post_gb") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + &secure_checkid($alias); + $msg = $q->param("msg"); + $tmp = $q->param("tmp"); + $id = $q->param("id"); + &post_gb; +} elsif ($var eq "edit_profile") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + $room = $q->param("room"); + &secure_checkid($alias); + &edit("edit_profile"); +} elsif ($var eq "edit_options") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + &secure_checkid($alias); + $tmp = $q->param("tmp"); + $id = $q->param("id"); + $room = $q->param("room"); + $col = $q->param("col"); + $secol = $q->param("secol"); + &edit("edit_options"); +} elsif ($var eq "rm_gb_alias") { + $alias = $q->param("alias"); + $tmpid = $q->param("tmpid"); + &secure_checkid($alias); + $tmp = $q->param("tmp"); + $id = $q->param("id"); + &rm_gb; +} else { + &error("Parameter fehlt"); +} + +########################### +##HAUPTTEIL DIESER DATEI:## +########################### + +sub gb_html { # Das Benutzerboard/Gästebuch. + my $message = $_[0]; + &start_html("Benutzerboard"); +if ($message eq "post_empty") { +print < + ACHTUNG! + +
+ Du wolltest soeben einen leeren Eintrag posten. Bitte schreib + + zuerst + + einen Text und poste + dann + ! +
+
+END +} elsif ($message eq "post_ok") { +print < + Meldung: + +
+ Vielen Dank für Deinen Beitrag. Wenn Du willst, kannst Du jetzt gleich noch einen Eintrag posten ... +
+
+END +} else { +print < + Falls Du Anregungen oder Verbesserungsvorschläge für die Community hast, dann poste doch einen kleinen Eintrag :-) + +
+END +} +print < + + + + + + + + + + +
+END + if (-e "data/guestbook") { + open (DATEI,"; + close DATEI; + print + $q->div(@datei); + } + print + $q->end_html; +} + + +sub post_gb { # Wenn etwas in ein Gästebuch eingetragen wird + &zeit; + if ($msg eq "") { + if ($id eq "y") { # Überprüfen, ob Benutzerboard- oder Privatgästebuch + &gb_html("post_empty"); + } else { + &alias_html("post_empty"); + } + exit; + } + $msg =~ s#<#<\;#g; + my $tmpath = ""; + if ($id eq "y") { + $tmpath = "data/guestbook"; + } else { + $tmpath = "data/user/gbooks/$tmp"; + } + open(GB,"$tmpath"); + my @gb = ; + close GB; + pop(@gb) if ($#gb > 99); + my @newdatei = "
$alias schrieb am $day.$month.$year um $hours:$min:$sec ...
$msg
\n"; + push(@newdatei,@gb); + open(GB,">$tmpath"); + print GB @newdatei; + close GB; + if ($id eq "y") { + &gb_html("post_ok"); + exit; + } else { + post_prv("$tmp","$alias hat soeben einen Pin in Dein Profil gehängt ... "); + &alias_html; + exit; + } +} + +sub rm_gb { # Gästebucheintrag entfernen + open(GB,"; + close GB; + my @newgbfile = (); + for ($i=0; $i <= $#gbfile; $i++) { + push(@newgbfile,$gbfile[$i]) if ($i != $id); + } + open(GB,">data/user/gbooks/$alias"); + print GB @newgbfile; + close GB; + &alias_html("rm_ok"); +} + +sub list_alias_html { # Liste aller Benutzer + &start_html("Alle Benutzer"); + opendir(REGISTERED,"data/user/options"); + my @users = readdir(REGISTERED); + closedir(REGISTERED); + my @liste = sort(@users); + my $nr = $#users-1; +print < + Es sind z.Z. genau $nr Benutzernamen in der Datenbank vorhanden! (Sortiert nach #, A-Z, a-z) + +
+
+END + foreach(@liste) { + if (-f "data/user/options/$_") { + print + $q->a( { -href=>"main2.pl?var=alias_html&alias=$alias&tmp=$_&tmpid=$tmpid" }, + "$_"), + " "; + } + } +print < + + +END +} + +sub alias_html { # Anzeigen eines Benutzerprofils + my $message = $_[0]; + open(COUNTS,"; + close COUNTS; + $counter++; + open(COUNTS,">data/user/counts/$tmp"); + print COUNTS $counter; + close COUNTS; + &start_html($tmp); +print < + Hier + gehts zur Gesamtübersicht ! +
+
+END +if ($message eq "rm_ok") { +print < + Meldung: + +
+ Der von Dir gewählte Eintrag wurde erfolgreich gelöscht. +
+
+END +} elsif ($message eq "post_empty") { +print < + ACHTUNG! + +
+ Du wolltest soeben einen leeren Eintrag posten. Bitte schreib + + zuerst + + einen Text und poste + dann + ! +
+END +} + open(PROFILE,"; + close PROFILE; +print < + Dieses Profil wurde insgesamt schon $counter mal aufgerufen ! +
+
+ Alias: $tmp +
+
+ Nachname: $data[0] +
+
+ Vorname: $data[1] +
+
+ Alter: $data[2] +
+
+ Wohnort: $data[3] +
+
+ E-Mail: + $data[4] +
+
+ ICQ-Nummer: $data[5] +
+
+ Homepage: + $data[6] +
+
+ Weiteres: +
+ $data[7] +
+ Hier kannst Du $tmp eine Nachricht hinterlassen! +
+ + + + + + + + +
+
+END +if (-e "data/user/gbooks/$tmp") { + open (DATEI,"; + close DATEI; + if ($alias ne $tmp) { + print @datei; + } else { +print < +
+ + + + +END +for($i=0; $i <= $#datei; $i++) { +print < + + + + +
+ $datei[$i] +
+ + +END +} +print < + + + + + +
+ + + + + + + +
+ +END +} +} + print + $q->end_html; +} + +sub edit_html { # Chat-Optionen / Benutzerprofil editieren + my ($method,$message) = @_; + &start_html("Benutzerprofil ändern"); + if ($method eq "edit_options_html") { + open(DATEI,"; + close DATEI; + if ($method eq "edit_options_html") { + chomp($data[0]); + if ($message eq "edit_options_ok") { +print < + open("main.pl?var=change_colors&alias=$alias&col=$col&secol=$secol&tmpid=$tmpid","reload"); + open("htdocs.pl?var=menu_html&alias=$alias&room=$room&col=$col&secol=$secol&tmpid=$tmpid","menu"); + +
+ Hinweis: +
+
+ Du hast soeben Deine Chat-Optionen erfolgreich editiert. Hier kannst Du Dein Profil erneuert editieren. Um + weiterzuchatten einfach Fenster schliessen! +
+
+END + } elsif ($message eq "edit_pw_wrong") { +print < + ACHTUNG! +
+
+ Du hast soeben versucht, dein Passwort zu ändern. Jedoch stimmte die Erste Eingabe nicht mit der Zweiten überein. + Bitte versuch es erneuert ... +
+
+END + } else { + print + $q->div( "Hier kannst Du Deine Chat-Optionen editieren!" ), + $q->hr; + } +print < + + + +
+ + + + + + + +
+
+ Dein Passwort + + (Gut merken !!) + +
+ +
+
+ +
+ Geb hier das Passwort erneuert ein: +
+ +
+
+
+
+ + + + + + +
+
+ + Auswahl von Farbe 1 +
+ (Farbe Deines Nicks): +
+ +
+
+ +
+ + Auswahl von Farbe 2 +
+ (Farbe Deiner Nachrichten): +
+ +
+
+
+
+ Beliebige Auswahl makieren und Farbe wählen. Um Deine Optionen abzuspeichern, + auf "Daten ändern" klicken! +
+
+END + open(COLORS,"; + close COLORS; + print @colors; + } elsif ($method eq "edit_profile_html") { + if ($message eq "edit_profile_ok") { +print < + Hinweis: + +
+ Du hast soeben Dein Profil erfolgreich editiert. Hier kannst Du Dein Profil erneuert editieren: +
+END + } else { + print + $q->div( "Hier kannst Du Dein Profil editieren!" ), + $q->hr; + } +print < + +
+ Dein Nachname: +
+ +
+
+
+ Dein Vorname: +
+ +
+
+
+ Dein Alter: +
+ +
+
+
+ Dein Wohnort: +
+ +
+
+
+ Deine E-Mail Adresse: +
+ +
+
+
+ Deine ICQ-Nummer: +
+ +
+
+
+ Deine Homepage: +
+ +
+
+
+ Weiteres: +
+ +
+END + } +print < + + + + + + + + + +END +} + + +sub edit { # Benutzerprofil od. Chat-Optionen abspeichern + my $method = $_[0]; + &zeit; + if ($method eq "edit_profile") { + &post($room,"($hours:$min:$sec) $alias hat sein Profil geändert ..."); + open(PROFILE,">data/user/profiles/$alias"); + print PROFILE $q->param('nachname')."\n".$q->param('vorname')."\n".$q->param('alter')."\n".$q->param('wohnort')."\n".$q->param('email')."\n".$q->param('icq')."\n".$q->param('homepage')."\n".$q->param('weiteres'); + close PROFILE; + &edit_html("edit_profile_html","edit_profile_ok"); + } elsif ($method eq "edit_options") { + if ($id ne $tmp) { + &edit_html("edit_options_html","edit_pw_wrong"); + exit; + } + &post($room,"($hours:$min:$sec) $alias hat seine Chateinstellungen geändert ..."); + open(OPTIONS,">data/user/options/$alias"); + print OPTIONS $id."\n".$col."\n".$secol; + close OPTIONS; + &edit_html("edit_options_html","edit_options_ok"); + } +} -- cgit v1.2.3