C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\pm.php


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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<?php
/* $Id: pm.php,v 1.3 2003/01/20 17:33:23 pbaecher Exp $ */
/*
          ThWboard - PHP/MySQL Bulletin Board System
        ==============================================
            (c) 2000, 2001 by
               Paul Baecher         <paul@thewall.de>
               Felix Gonschorek   <funner@thewall.de>

          download the latest version:
            http://www.thwboard.de

          This  program is  free  software;  you can
          redistribute it and/or modify it under the
          terms of the GNU General Public License as
          published by the Free Software Foundation;
          either  version 2 of  the License,  or (at
          your option) any later version.

        ==============================================

*/

include "./inc/header.inc.php";

$config['pmqouta'] = 1;

// clearing DB from old Pms
if ( $config['pmalive'] > && (time() % 60 55) )
{
    
$limit_date time()-($config['pmalive']*(60*60*24));
    
thwb_query("DELETE FROM ".$pref."pm WHERE pmtime < ".$limit_date."");
}

if( !
$config['privatemessages'] )
{
    
$navpath .= "Private Messages";

    
message("Sorry""Private Messages wurden vom Administrator deaktiviert.");
}

if( 
$g_user['userid'] == )
{
    
$navpath .= "Private Messages";

    
message("Nur f&uuml;r Mitglieder""Diese Funktion ist nur f&uuml;r Mitglieder. Sie k&ouml;nnen sich <a href=\"register.php\">hier</a> kostenlos registrieren.");
}

if( 
$action == "do_deleteall" )
{
    
$pm $HTTP_POST_VARS['pm'];
    
    
thwb_query("DELETE FROM ".$pref."pm WHERE pmtoid=$g_user[userid]");
    
header("Location: pm.php");
}
elseif( 
$action == "deleteall" )
{
    
$navpath .= "Private Messages";

    
message('Bestaetigung''<form name="theform" method="post" action="pm.php">
  M&ouml;chten Sie wirklich alle Nachrichten l&ouml;schen?<br><br>
  <input type="hidden" name="pm[pmid]" value="' 
$pm['pmid'] . '">
  <input type="hidden" name="action" value="do_deleteall">
  <input class="tbbutton" type="submit" name="Submit" value="L&ouml;schen &gt;&gt;">
</form>'
);
}
elseif( isset(
$deletepm) )
{
    
thwb_query("DELETE FROM ".$pref."pm WHERE ( pmtoid=$g_user[userid] ) AND ( pmid = ".intval($deletepm)." )");
    
header("Location: pm.php");
}
elseif( isset(
$deletepms) )
{
    
$deletepms $HTTP_POST_VARS['deletepms'];

    if( 
$deletepms )
    {
        while( list(
$k$v) = each($deletepms) )
            
$deletepms[$k] = intval($v);
        
        
thwb_query("DELETE FROM ".$pref."pm WHERE pmtoid=$g_user[userid] AND pmid IN(" addslashes(implode(','$deletepms)) . ")");
        
header("Location: pm.php");
        exit;
    }
    else
    {
        
$navpath .= "Private Messages";

        
message('Fehler''Bitte markieren Sie erst eine oder mehrere Nachricht(en).');
    }
}
elseif( 
$action == "new" )
{
    if( 
$send )
    {
        
// http://www.securiteam.com/securitynews/5FP0C204KE.html
        
$action $HTTP_POST_VARS['action'];
        
$errmsg '';
        if( 
strlen($pm[username]) < )
        {
            
$errmsg .= "Bitte geben Sie einen Empf&auml;nger an<br>";
        }

        if( 
strlen($pm[pmtopic]) < )
        {
            
$errmsg .= "Betreff ist zu kurz! (mindestens 3 Zeichen)<br>";
        }

        if( 
strlen($pm[pmtext]) < )
        {
            
$errmsg .= "Der Text ist zu kurz! (mindestens 3 Zeichen)<br>";
        }
        
        if( 
strlen($pm[pmtext]) > $config[pm_maxlength] )
        {
            
$errmsg .= "Der Text ist zu lang! (maximal $config[pm_maxlength] Zeichen)<br>";
        }

        
$r_user thwb_query("SELECT userid, useremail, groupids FROM ".$pref."user WHERE username='" addslashes($pm['username']) . "'");
        if( 
mysql_num_rows($r_user) < )
        {
            
$errmsg.="Der Empf&auml;nger existiert nicht!<br>";
        }
        else
        {
            
$user mysql_fetch_array($r_user);
            if( 
$user['groupids'] == ',,' )
                
$user['groupids'] = '-1';
            else
                
$user['groupids'] = substr($user['groupids'], 1strlen($user['groupids']) - 2);
        }

        if( 
strlen($errmsg) > )
        {
            
$navpath .= "Private Messages";

            
message("Fehler""Es sind leider folgende Fehler aufgetreten:<br><br><font color='$style[color_err]'>$errmsg</font>");
        }

        if ( 
$pm['pmmethod'] == 'pm' 
        {
    
            
// full inbox?
            
$r_topm thwb_query("SELECT count(pmid) FROM ".$pref."pm WHERE pmtoid=$user[userid]");
            list(
$topmcount) = mysql_fetch_row($r_topm);
            
$r_frompm thwb_query("SELECT count(pmid) FROM ".$pref."pm WHERE pmtoid=$g_user[userid]");
            list(
$frompmcount) = mysql_fetch_row($r_frompm);
            
            
/* wenn entweder der sender *oder* der empfaenger NOPMLIMIT haben, dann kann die nachricht trotzdem
               gesendet werden. so kann ein user der das flag hat unendlich viele pms schicken und empfangen */
            
$P = new Permission($g_user['groupids']);
            
$toP = new Permission($user['groupids']);

            if( 
$topmcount >= $config['max_privmsg'] && !($P->has_permissionP_NOPMLIMIT ) || $toP->has_permissionP_NOPMLIMIT )) )
            {
                
$navpath .= "Private Messages";

                
message('Fehler''Die Nachricht konnte nicht versendet werden: Die Private Message Box des Empf&auml;ngers ist voll.');
            }
            else
            {
                
// send msg!
                
thwb_query("INSERT INTO ".$pref."pm (pmfromid, pmtoid, pmtopic, pmtext, pmtime, pmflags, pmfolder)
                    VALUES (
$g_user[userid]$user[userid],'" addslashes($pm['pmtopic']) . "','" addslashes($pm['pmtext']) . "',".time().", 1, 0);");
                
                if( (
$frompmcount $config['max_privmsg'] && !$override) && $pm['pmsaveinoutbox'] == )
                {
                    
thwb_query("INSERT INTO ".$pref."pm (pmtoid, pmfromid, pmtopic, pmtext, pmtime, pmflags, pmfolder)
                    VALUES (
$g_user[userid]$user[userid],'" addslashes($pm['pmtopic']) . "','" addslashes($pm['pmtext']) . "',".time().",0 , 1);");
                }
                
$navpath .= "Private Messages";

                
message("Message verschickt""Ihre Private Message wurde verschickt!<br><a href=\"pm.php\">Private Message Center</a>");
            }
        }
        elseif ( 
$pm[pmmethod] == 'email' 
        {
        
        
// SEND PM as E-Mail
        
$Pmmail = new Template("templates/mail/pmsg.mail");
        eval(
$Pmmail->GetTemplate("mail_body"));
        @
mail($user[useremail],"Private Nachricht: ".$pm[pmtopic], $mail_body"From: ".$g_user[username]." <".$g_user[useremail].">");
        
        
        if( ( 
$frompmcount $config['max_privmsg'] ) AND ( $pm[pmsaveinoutbox] == ) )
        {
            
thwb_query("INSERT INTO ".$pref."pm (pmtoid, pmfromid, pmtopic, pmtext, pmtime, pmflags, pmfolder)
                VALUES (
$g_user[userid]$user[userid],'" addslashes($pm[pmtopic]." *E-Mail*") . "','" addslashes($pm[pmtext]) . "',".time().",0 , 1);");
        }
        
$navpath .= "Private Messages";

        
message("Message verschickt""Ihre Private Message wurde als E-Mail verschickt!<br><a href=\"pm.php\">Private Message Center</a>");

        }
    }
    else
    {
        
$TFrame = new Template("templates/" $style['styletemplate'] . "/frame.html");
        
$TMsg = new Template("templates/" $style['styletemplate'] . "/newprivmsg.html");
        if ( 
$config['use_email'] == )
        {
            
$print_emailradio "<input type=radio name=pm[pmmethod] value=email> E-Mail";
        }
        
        if( 
$replyto )
        {
            
$r_pm thwb_query("SELECT pm.pmtopic, pm.pmfolder, user.username
                FROM "
.$pref."pm AS pm, ".$pref."user AS user
                WHERE pm.pmid="
.intval($replyto)." AND pm.pmfromid=user.userid AND pmtoid=$g_user[userid]");

            
$pm mysql_fetch_array($r_pm);

            if( !
strstr($pm['pmtopic'], 'RE: ') )
            {
                
$pm['pmtopic'] = 'RE: ' $pm['pmtopic'];
            }
            
            
$pm['username'] = htmlspecialchars($pm['username']);
        }
        elseif ( 
$forward )
        {
            
$r_pm thwb_query("SELECT pm.pmtopic, pm.pmfolder, pm.pmtext, user.username
                FROM "
.$pref."pm AS pm, ".$pref."user AS user
                WHERE pm.pmid="
.intval($forward)." AND pm.pmfromid=user.userid AND pmtoid=$g_user[userid]");

            
$pm mysql_fetch_array($r_pm);

            if( !
strstr($pm['pmtopic'], 'FW: ') )
            {
                
$pm['pmtopic'] = 'FW: ' $pm['pmtopic'];
            }
            
$pm['pmtext'] = "[quote][i]Zitat von $pm[username][/i]\n$pm[pmtext][/quote]";
            
$pm['username'] = "";

        }
        elseif ( 
$insert )
        {
            
$r_pm thwb_query("SELECT pm.pmtopic, pm.pmfolder, pm.pmtext, user.username
                FROM "
.$pref."pm AS pm, ".$pref."user AS user
                WHERE pm.pmid="
.intval($insert)." AND pm.pmfromid=user.userid AND pmtoid=$g_user[userid]");

            
$pm mysql_fetch_array($r_pm);

            if( !
strstr($pm['pmtopic'], 'RE: ') )
            {
                
$pm['pmtopic'] = 'RE: ' $pm['pmtopic'];
            }
            
$pm['pmtext'] = "[quote][i]$pm[username] schrieb :[/i]\n$pm[pmtext][/quote]";
            
        }
        
        
$navpath .= 'Neue Privatnachricht';
        
        eval(
$TMsg->GetTemplate("CONTENT"));
        eval(
$TFrame->GetTemplate());
    }

}
elseif( 
$action == "show" )
{
    
$TFrame = new Template("templates/" $style['styletemplate'] . "/frame.html");
    
$TMsg = new Template("templates/" $style['styletemplate'] . "/showprivmsg.html");

    
$r_pm thwb_query("SELECT pm.pmid, pm.pmfromid, pm.pmtoid, pm.pmtopic, pm.pmtext, pm.pmtime,
    pm.pmflags, pm.pmfolder, user.username, user.usertitle
        FROM "
.$pref."pm as pm, ".$pref."user as user
        WHERE pm.pmid='"
.intval($pm['pmid'])."' AND pm.pmfromid=user.userid
        ORDER BY pm.pmtime DESC"
);

    
$pm mysql_fetch_array($r_pm);
    
$pm['tousername'] = $g_user['username'];
    
    if( 
$pm['pmtoid'] != $g_user['userid'] )
    {
        
message("Error""You don't have permission to access this page");
    }

    if( 
$pm['pmfolder'] == )
    {
        
$pm['pmfromid'] = $g_user['userid'];
        
$pm['userid'] = $g_user['userid'];
        
$pm['tousername'] = $pm['username'];
        
$pm['username'] = $g_user['username'];
        
$pm['usertitle'] = $g_user['usertitle'];
    }

    
$pm['pmtopic'] = parse_code($pm['pmtopic']);
    
$pm['pmtext'] = parse_code($pm['pmtext'], 111$config['smilies']);
    
$pm['pmtime'] = form_date($pm['pmtime']);
    
$pm['username'] = parse_code($pm['username']);


    
// als gelesen markieren!!
    
thwb_query("UPDATE ".$pref."pm SET pmflags=0 WHERE pmid='".intval($pm['pmid'])."'");

    
$navpath .= 'Privatnachricht Ansehen';

    eval(
$TMsg->GetTemplate("CONTENT"));
    eval(
$TFrame->GetTemplate());
}
else
{
    
    
$Tpmrow = new Template("templates/" $style['styletemplate'] . "/pmrow.html");
    
$Tpmnomsg = new Template("templates/" $style['styletemplate'] . "/pmnomessages.html");
    
$TFrame = new Template("templates/" $style['styletemplate'] . "/frame.html");

    
// private msgs
    
$r_pm thwb_query("SELECT pm.pmid, pm.pmfromid, pm.pmtopic, pm.pmtext, pm.pmtime,
        pm.pmflags, pm.pmfolder, user.username
        FROM "
.$pref."pm as pm, ".$pref."user as user
        WHERE pm.pmtoid=
$g_user[userid] AND pm.pmfromid=user.userid
        ORDER BY pm.pmtime DESC"
);

    
$msgcount mysql_num_rows($r_pm);
    if( 
$msgcount >= $config['max_privmsg'] )
    {
        
$msgcount '<font color="' $style['color_err'] . '"><b>' $msgcount '</b></font>';
    }

    if( !
$folder || $folder == )
    {
        
$folder 0;
        
$inboxsel ' selected';
        
$from_to 'Von';
    }
    else
    {
        
$folder 1;
        
$outboxsel ' selected';
        
$from_to 'An';
    }

    
$inbox_mails 0;
    
$inbox_mails_new 0;
    
$outbox_mails 0;
    while( 
$pm mysql_fetch_array($r_pm) )
    {
        if( 
$pm['pmfolder'] == )
        {
            
// Writing Inbox
            
$i_in == $cellbg $style[CellA] : $cellbg $style[CellB];
        
            
$pm['pmtopic'] = parse_code($pm['pmtopic']);
            
$pm['pmtime'] = form_date($pm['pmtime']);

            if( 
$pm['pmflags'] == )
            {
                
$pm['pmflags'] = "*new*";
                
$inbox_mails_new++;
            }
            else
            {
                
$pm['pmflags'] = "&nbsp;";
            }
            
$pm['username'] = parse_code($pm['username']);
            
            eval(
$Tpmrow->GetTemplate("PMROWS_INBOX"));
            
$inbox_mails++;
            
            
$i_in++;
        } 
        else 
        {
            
// Writing Outbox
            
$i_out == $cellbg $style[CellA] : $cellbg $style[CellB];
        
            
$pm['pmtopic'] = parse_code($pm['pmtopic']);
            
$pm['pmtime'] = form_date($pm['pmtime']);

            if( 
$pm['pmflags'] == )
            {
                
$pm['pmflags'] = "*new*";
                
$outbox_mails_new++;
            }
            else
            {
                
$pm['pmflags'] = "&nbsp;";
            }
            
$pm['username'] = parse_code($pm['username']);
    
            eval(
$Tpmrow->GetTemplate("PMROWS_OUTBOX"));
            
$outbox_mails++;
            
            
$i_out++; // dp: die "++" haben gefehlt =)
        
}
    }
    
    if( 
$inbox_mails == )
    {
        eval(
$Tpmnomsg->GetTemplate("PMROWS_INBOX"));
    }
    if( 
$outbox_mails == )
    {
        eval(
$Tpmnomsg->GetTemplate("PMROWS_OUTBOX"));
    }

    
$full_box $inbox_mails $outbox_mails;
    
$diskquota round( ( $full_box $config['max_privmsg'] ) * 100);
    
    if (
$inbox_mails_new == )
    {
        
$msg_new_msgs[inbox] = ", davon keine ungelesen";
    }
    elseif ( 
$inbox_mails_new == 
    {
        
$msg_new_msgs[inbox] = ", davon eine Nachricht ungelesen";
    }
    else 
    {
        
$msg_new_msgs[inbox] = ", davon $inbox_mails_new Nachricht ungelesen";
    }
    
// Generating Grafic Diskquota
    
if ( $config['pmqouta'] == )
    {
        if (
$config[pmalive] > 0
        {
            
$pic[start_sentence] = "Achtung: Alle Nachrichten, die älter sind als ".$config[pmalive]." Tage werden automatisch gelöscht";
        }
        else
        {
            
$pic[start_sentence] = "Bitte achten Sie auf das Nachrichtenlimit. Sollte ihr Konto überfüllt sein, können Sie keine Nachrichten mehr empfangen.";
        }
        if ( 
$diskquota == 
        {
            
$pic[imageline] = "&nbsp;";        
        }
        elseif ( 
$diskquota 25 
        {
            
$pic[start_width] = 10;
            
$pic[end_width] = 10;
            
$pic[middle_width] = (300*($diskquota/100))-($pic[start_width]+$pic[end_width]);
        } 
        else 
        {
            
$pic['start_width'] = 29;
            
$pic['end_width'] = 29;
            
$pic['middle_width'] = (300*($diskquota/100))-($pic[start_width]+$pic[end_width]);
        }
        
$Tquota = new Template("templates/" $style['styletemplate'] . "/pmquota.html");
        eval(
$Tquota->GetTemplate("QUOTA"));
    }
    
// Initiating Template
    
$Tpm = new Template("templates/" $style['styletemplate'] . "/pm.html");
    
    
$navpath .= 'Privatnachrichten &Uuml;bersicht';
    
    eval(
$Tpm->GetTemplate("CONTENT"));
    eval(
$TFrame->GetTemplate());
}

?>