summaryrefslogtreecommitdiff
path: root/0.4.7a2/index.pl
blob: 078a2fd5d8a63920353af28f36969596178c212b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#!/usr/bin/perl -w

# yChat - Copyright by Paul C. Bütow

use CGI;
$q = new CGI;
require config;
print
 $q->header;

#####################################
##WELCHE SUB MUß AUFGERUFEN WERDEN?##
#####################################

$var = $q->param("var");
$alias = $q->param("alias");
$pw = $q->param("pw");
$tmp = $q->param("tmp");

if ($var eq "create_alias_html") {
 &create_alias_html;
} elsif ($var eq "create_alias") {
 &create_alias;
} elsif ($var eq "login_html") {
 $tmp = $q->param("tmp");
 &login_html;
} elsif ($alias eq "") {
 &login_html;
} else {
 &checklogin;
}

sub login_html { # Erste Startseite
&check_online;
local $counter = undef;
open(COUNT,"<data/count");
 $counter = <COUNT>;
close COUNT;
$counter++;
open(COUNT,">data/count");
 print COUNT $counter;
close COUNT;
opendir(USERS,"data/online/users");
 local @users = readdir(USERS);
closedir(USERS);
opendir(REGISTRED,"data/user/options");
 local @registred = readdir(REGISTRED);
closedir(REGISTRED);
local ($logtin,$users) = ($#users-1,$#registred-1);
&start_html("Created & Copyright by Paul C. Bütow","start");
print <<END;
 <center>
  <table width=500>
   <tr>
    <td>
     <center>
      <table>
       <tr>
        <td>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
 WIDTH=240 HEIGHT=240>
 <PARAM NAME=movie VALUE="$gfxpath/yIntro.swf">
 <PARAM NAME=loop VALUE=false>
 <PARAM NAME=menu VALUE=false>
 <PARAM NAME=quality VALUE=high>
 <PARAM NAME=scale VALUE=noborder>
 <PARAM NAME=wmode VALUE=opaque>
 <PARAM NAME=bgcolor VALUE=#005146>
 <EMBED src="$gfxpath/yIntro.swf" loop=false menu=false quality=high scale=noborder wmode=opaque bgcolor=#005146
 WIDTH=240 HEIGHT=240 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
        </td>
        <td>
         <div>
          yChat: Version $version
          <br><br>
          Letztes Update: $datum
          <br><br>
          Seitenaufrufe: $counter
          <br><br>
          Benutzer registriert: $users
          <br><br>
          Benutzer online: $logtin
          <br><br>
          Webmaster: <a href="mailto:mail\@paulbuetow.de">Paul C. Bütow</a>
          <br><br>
          yChat-HP: <a href="http://www.home.yChat.de">home.yChat.de</a>
         </div>
        </td>
       </tr>
      </table>
     </center>
    </div>
    <br>
    <br>
END
 if ($tmp eq "true") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Wahrscheinlich existiert Dein Alias "$alias" nicht,
      <br>
      Du hast Dich verschrieben oder das Passwort ist falsch.
      <br>
      Versuch es erneuert !
     </div>
END
 } elsif ($tmp eq "quit") {
print <<END;
     <div>
      Du hast soeben den Chat verlassen.
      <br>
      Um den Chat erneuert zu betreten, einfach Daten eingeben und auf "Los Geht's" klicken :-)
     </div>
END
 } elsif ($tmp eq "banned") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Dein Alias "$alias" wurde verbannt.
      <br>
      Z.z. kannst Du Dich leider nicht in den Chat einloggen.
      <br>
      Sorry!
     </div>
END
 } elsif ($tmp eq "kick") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Du wurdest soeben aus dem Chat katapultiert!
      <br>
      Schlechtes Verhalten mag die Ursache hierfür sein.
      <br>
      Sorry!
     </div>
END
 } elsif ($var eq "create_alias") {
print "<div>Du hast sich soeben in die Datenbank eingetragen. Einfach auf  \"Los Geht's\" klicken :-)</div>";
 } else {
print <<END;
     <div>
      Herzlich willkommen!
      <br>
      Einfach Daten eingeben und auf "Los Geht's" klicken :-)
     </div>
END
  }
print <<END;
 <hr>
 <form name="login" action="index.pl" method="post">
 <input type="hidden" name="tmp" value="true">
 <table>
  <tr>
   <td>
    <div>
     Dein Alias:
     <br>
     <input name="alias" value="$alias">
    </div>
   </td>
   <td>
    <div>
     Dein Passwort:
     <br>
     <input type="password" name="pw" value="$pw">
    </div>
   </td>
  </tr>
 </table>
 <br>
 <br>
 <div>
  Solltest Du noch keinen Nick besitzen, dann auf "Registrieren" klicken!
 </div>
 <br>
 <table>
  <tr>
   <td>
    <font color="ffffff">
     <input type="submit" value="Los geht's!">
    </font>
 </form>
   </td>
   <td>
 <form action="index.pl">
    <input type="hidden" name="var" value="create_alias_html">
     <font color="ffffff">
      <input type="submit" value="Registrieren">
     </font>
 </form>
    </td>
   </tr>
 </table>
 <hr>
    </td>
   </tr>
  </table>
 </center>
</body>
</html>
END
# if ($logtin == 0) {
#  &list_dir("data/msgs");
#  &list_dir("data/online/rstat",2);
#  foreach(@dir) {
#   unlink("data/msgs/$_");
#   unlink("data/online/ident/$_");
#  }
#  foreach(@dir2) {
#   unlink("data/online/rstat/$_");
#  }
# }
# # Falls d. Skript das Raumverz. gelöscht hat, neu anlegen
 if (-d "data/online/rooms") {
 } else {
  mkdir "data/online/rooms", 0777;
 }
}


sub create_alias_html { # HTML-Form für Erstellung eines neuen Benutzers.
local $reload = $_[0];
&start_html("Registration");
print <<END;
 <center>
  <table width=500>
   <tr>
    <td>
END
 if ($reload eq "alias_exists") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Der von Dir gewählte Benutzername "$alias" existiert in unserer Datenbank bereits. Bitte versuch es erneuert mit
      einem anderen Benutzernamen !
     </div>
     <hr>
END
} elsif ($reload eq "pw_wrong") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Deine beiden Passworteingaben stimmen nicht überein. Bitte geb das Passwort erneuert an um sicherzugehen, daß
      kein falsches Passwort abgespeichert wird !
     </div>
     <hr>
END
} elsif ($reload eq "alias_prohibited") {
print <<END;
     <div class=b>
      ACHTUNG!
     </div>
     <div>
      Dein gewählter Benutername "$alias" enthält illegale Zeichen. Bitte versuch einen anderen Benutzernamen!
     </div>
     <hr>
END
} else {
print <<END;
     <div>
      Hier kannst Du Dich registrieren. Bitte beachte, daß die Passworteingabefelder übereinstimmen!
     </div>
     <hr>
END
}
print <<END;
     <form action="index.pl">
      <input type="hidden" name="var" value="create_alias">
      <div>
       Dein Alias:
       <font color="ffa500">
        (Muß angegeben werden)
       </font>
       <br>
       <input name="alias" VALUE="$alias">
      </div>
      <br>
      <div>
       Dein gewünschtes Passwort:
       <br>
       <input type="password" name="pw" value="$pw">
      </div>
      <br>
      <div>
       Geb hier Dein Passwort erneuert ein:
       <br>
       <input type="password" name="tmp">
      </div>
      <br>
      <font color=ffffff>
       <input type="submit" value="Registrieren">
      </font>
      <br>
    </form>
    <hr>
    <div>
     Um den Chat zu betreten müssen die Daten nach der Registration auf der Startseite erneuert bestätigt werden !
    </div>
   </td>
  </tr>
 </table>
</center>
</body>
</html>
END
}

sub checklogin { # Überprüfen, ob die Login-Daten korrekt sind.
 my $lognotexists = "true";
 opendir(USERDIR,"data/user/options");
  my @userdir = readdir(USERDIR);
 closedir(USERDIR);
 foreach $user (@userdir) {
  if ($user eq $alias) {
   open(OPTIONS,"<data/user/options/$alias");
    my @options = <OPTIONS>;
   close OPTIONS;
   chomp($options[0]);
   if ($options[0] eq $pw) {
    open(BAN,"<data/ban");
     my @ban = <BAN>;
    close BAN;
    foreach(@ban) {
     if ($_ eq "$alias\n") {
      $tmp = "banned";
      &login_html;
      exit;
     }
    }
    if ($options[1] eq undef) {
     $col = "ffffff";
    } else {
    chomp($options[1]);
    $col = $options[1];
    }
    if ($options[2] eq undef) {
     $secol = "ffffef";
    } else {
     $secol = $options[2];
    }
    $tmpid = time;
    open(IDENT,">data/online/ident/$alias");
     print IDENT $ENV{'REMOTE_ADDR'}."\n".$tmpid;
    close IDENT;
    open(LASTLOGIN,">data/user/lastlogin/$alias");
     print LASTLOGIN time;
    close LASTLOGIN;
    &frameset_html;
    exit;
   } else {
    $lognotexists = "false";
   }
  }
 }
 &login_html;	# Falls Login-Daten inkorrekt sind, zurück zur Startseite.
}

sub create_alias { # Erstellung eines neuen Benutzers.
 if ($alias =~ /[\W]/ || $alias eq "") {
  &create_alias_html("alias_prohibited");;
  exit;
 } elsif ($pw ne $tmp) {
  &create_alias_html("pw_wrong");
  exit;
 }
 opendir(USERDIR,"data/user/options");
  my @user = readdir(USERDIR);
 close USERDIR;
 foreach $user (@user) {
  if ($user eq $alias) {
   &create_alias_html("alias_exists");
   exit;
  }
 }
 open(OPTIONS,">data/user/options/$alias");
  print OPTIONS $pw."\n";
 close OPTIONS;
 local $number = $#user;
 &zeit;
 &post("Cyberbar","<i><font color=ffffff>($hours:$min:$sec)</font> <font color=ffa500>$alias [$number] hat sich soeben als neuer Benutzer registriert :-) ...</font></i>");
 &login_html;
}

sub frameset_html {
print <<END;
<html>
 <head>
  <title>
   $title - Created & Copyright by Paul C. Bütow
  </title>
 </head>
<frameset border=0 frameborder=0 framespacing=0 cols="130,*">
 <frameset border=0 frameborder=0 framespacing=0 rows="300,*,55">
  <frame name="online" src="online.pl?room=Cyberbar&alias=$alias&tmpid=$tmpid">
  <frame src="htdocs.pl">
  <frameset border=0 frameborder=0 framespacing=0 cols="70,*">
   <frame name="logo" src="htdocs.pl?var=logo_html" scrolling="no">
   <frame name="reload" src="htdocs.pl" scrolling="no">
  </frameset>
 </frameset>
 <frameset border=0 frameborder=0 framespacing=0 rows="60,*,55">
  <frame name="menu" src="htdocs.pl?alias=$alias&var=menu_html&room=Cyberbar&col=$col&secol=$secol&tmpid=$tmpid" scrolling="no">
  <frame name="main" src="push.pl?room=Cyberbar&alias=$alias&tmpid=$tmpid">
  <frame name="input" src="input.pl?alias=$alias&room=Cyberbar&col=$col&secol=$secol&tmp=login&tmpid=$tmpid" scrolling="no">
 </frameset>
</frameset>
</html>
END
}